Skip to content
Browse files

Added numerous other fields to the font copyright notice, including T…

…rademark, Designer, Vendor URL and License information.
  • Loading branch information...
1 parent a50d62d commit d626df1c656ee5e4afdfbd63cc38e35f9a46005a @sorccu committed Sep 25, 2009
Showing with 54 additions and 38 deletions.
  1. +14 −3 generate/lib/Cufon.php
  2. +40 −6 generate/lib/FontForgeScript.php
  3. +0 −8 generate/lib/SVGFont.php
  4. +0 −21 generate/lib/SVGFontContainer.php
View
17 generate/lib/Cufon.php
@@ -103,15 +103,26 @@ public static function generate($file, array $options)
Cufon::log('Converting to SVG with filename %s', $svgFile);
+ $script->printNameIDs();
$script->generate($svgFile);
- $script->execute();
+
+ $output = trim($script->execute());
$fonts = array();
+ $copyright = '';
+
+ if (!empty($output))
+ {
+ $copyright = self::createJSDocComment(
+ "The following copyright notice may not be removed under " .
+ "any circumstances.\n\n${output}");
+ }
+
foreach (SVGFontContainer::fromFile($svgFile, $options) as $font)
{
$fonts[$font->getId()] = sprintf("%s%s(%s);\n",
- self::createJSDocComment($font->getCopyright()),
+ $copyright,
$options['callback'],
$font->toJavaScript()
);
@@ -132,7 +143,7 @@ public static function createJSDocComment($comment)
return '';
}
- $lines = explode("\n", wordwrap($comment, 72));
+ $lines = explode("\n", wordwrap(trim($comment), 80));
for ($i = 0, $l = count($lines); $i < $l; ++$i)
{
View
46 generate/lib/FontForgeScript.php
@@ -78,7 +78,7 @@ public function detachAndRemoveGlyphs()
}
/**
- * @return void
+ * @return string
*/
public function execute()
{
@@ -90,7 +90,7 @@ public function execute()
chmod($filename, 0777);
- $command = sprintf('env %s -script %s 2>&1', CUFON_FONTFORGE, escapeshellarg($filename));
+ $command = sprintf('env %s -script %s', CUFON_FONTFORGE, escapeshellarg($filename));
Cufon::log('Executing command: %s', $command);
@@ -100,14 +100,14 @@ public function execute()
exec($command, $output, $status);
- Cufon::log('Exited with status %d, output: %s', $status, implode(' / ', $output));
+ Cufon::log('Exited with status %d', $status);
if ($status > 0)
{
throw new ConversionException('Conversion failed');
}
- return $output;
+ return implode("\n", $output);
}
/**
@@ -132,6 +132,42 @@ public function generate($filename)
}
/**
+ * @return FontForgeScript
+ */
+ public function printNameIDs()
+ {
+ $fields = array(
+ 'Copyright' => array(0, '$copyright'),
+ 'Trademark' => array(7, null),
+ 'Full name' => array(4, null),
+ 'Description' => array(10, null),
+ 'Manufacturer' => array(8, null),
+ 'Designer' => array(9, null),
+ 'Vendor URL' => array(11, null),
+ 'License information' => array(14, null)
+ );
+
+ foreach ($fields as $field => $info)
+ {
+ list($code, $alt) = $info;
+
+ $this->commands[] =
+ "if (GetTTFName(0x409, ${code}) != '')\n" .
+ "\tPrint('${field}:')\n" .
+ "\tPrint(GetTTFName(0x409, ${code}))\n" .
+ "\tPrint('')\n" .
+ (!empty($alt) ?
+ "elseif (${alt} != '')" .
+ "\tPrint('${field}:')\n" .
+ "\tPrint(${alt})\n" .
+ "\tPrint('')\n" : '') .
+ "endif";
+ }
+
+ return $this;
+ }
+
+ /**
* @param int $at
* @return FontForgeScript
*/
@@ -150,8 +186,6 @@ public function open($filename)
{
$this->commands[] = sprintf('Open("%s")', addslashes($filename));
- chmod($filename, 0777);
-
return $this;
}
View
8 generate/lib/SVGFont.php
@@ -38,14 +38,6 @@ public function __toString()
/**
* @return string
*/
- public function getCopyright()
- {
- return $this->container->getCopyright();
- }
-
- /**
- * @return string
- */
public function getId()
{
$faces = $this->document->xpath('//font-face');
View
21 generate/lib/SVGFontContainer.php
@@ -43,27 +43,6 @@ public function __construct(SimpleXMLElement $document, array $options)
}
/**
- * @return string
- */
- public function getCopyright()
- {
- $parts = array();
-
- foreach ($this->document->xpath('//metadata') as $meta)
- {
- $content = preg_replace('/\.(?=\p{L})/u', '. ', trim((string) $meta));
-
- $lines = explode("\n", $content);
-
- array_splice($lines, 0, 2);
-
- $parts[] = implode("\n", $lines);
- }
-
- return implode("\n\n", $parts);
- }
-
- /**
* @return array of SVGFont
*/
public function getFonts()

0 comments on commit d626df1

Please sign in to comment.
Something went wrong with that request. Please try again.