]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5870 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Apr 2023 10:30:56 +0000 (12:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Apr 2023 10:30:56 +0000 (12:30 +0200)
app/Jobs/FluidbookCompiler.php
resources/tools/fonts/convertrn.pe [new file with mode: 0644]

index 42844d7259ef887108df2eff4ab051bc4eef2bf4..456abf8307f695fadeea735b02d022a893e90188 100644 (file)
@@ -3516,37 +3516,49 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
     {
         $f = $this->wdir . '/' . $fontFile;
         $e = explode('.', $f);
-        $ext = array_pop($f);
+        $ext = array_pop($e);
         $hash = 'fb_' . substr(md5($fontFile), 0, 10);
         if (!isset($this->cssfont[$hash])) {
             $final = $hash . '.woff';
             $dest = $this->wdir . '/' . $final;
             if (!file_exists($dest) || filemtime($dest) < filemtime($f)) {
-                $fontforge = new cubeCommandLine('convertrn.pe');
-                $fontforge->setPath(CONVERTER_PATH);
+                $script = resource_path('tools/fonts/convertrn.pe');
+                if (!is_executable($script)) {
+                    chmod($script, 755);
+                }
+                $fontforge = new CommandLine('fontforge');
+                $fontforge->setArg('-script', $script);
                 $fontforge->setArg(null, $f);
                 $fontforge->setArg(null, $dest);
                 $fontforge->execute();
+                $fontforge->debug();
             }
             $this->vdir->copy($dest, 'data/fonts/' . $hash . '.woff');
-            $cmd = "font-line report $f";
-            $fontline = `$cmd`;
-            $report = explode("\n", $fontline);
+            $fontline = new CommandLine('font-line');
+            $fontline->setArg(null, 'report');
+            $fontline->setArg(null, $f);
+            $fontline->execute();
+            $fontline->debug();
+            $report = explode("\n", $fontline->getOutput());
 
             foreach ($report as $item) {
                 $item = trim($item);
+                if (!stristr($item, ':')) {
+                    continue;
+                }
                 list($k, $v) = explode(':', $item, 2);
+                $v = trim($v);
                 if ($k == '[head] Units per Em') {
-                    $fontHeight = trim($v);
+                    $fontHeight = $v;
                 }
                 if ($k == '[OS/2] CapHeight') {
-                    $fontCapHeight = trim($v);
+                    $fontCapHeight = $v;
                 }
                 if ($k == '[OS/2] TypoAscender') {
-                    $ascender = abs(trim($v));
+                    $ascender = abs($v);
                 }
                 if ($k == '[OS/2] TypoDescender') {
-                    $descender = abs(trim($v));
+                    $descender = abs($v);
                 }
             }
             $capHeight = 1;
diff --git a/resources/tools/fonts/convertrn.pe b/resources/tools/fonts/convertrn.pe
new file mode 100644 (file)
index 0000000..2423bae
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/fontforge -script
+Open($1)
+Print("Open font ",$1)
+SetOS2Value("FSType",0);
+if($argc>3)
+       Print("Change name to ",$3)
+       SetFontNames($3,$3,$3,'Regular','','1.0')
+       SetTTFName(0x409,0,"-")
+       SetTTFName(0x409,1,$3)
+       SetTTFName(0x409,3,$3)
+       SetTTFName(0x409,4,$3)
+       SetTTFName(0x409,5,"1.0")
+       SetTTFName(0x409,6,$3)
+       SetTTFName(0x409,7,"-")
+       SetTTFName(0x409,8,"-")
+       SetTTFName(0x409,9,"-")
+       SetTTFName(0x409,10,"-")
+       SetTTFName(0x409,11,"-")
+       SetTTFName(0x409,12,"-")
+       SetTTFName(0x409,13,"-")
+       SetTTFName(0x409,14,"-")
+       SetTTFName(0x409,16,$3)
+       SetTTFName(0x409,17,$3)
+       SetTTFName(0x409,18,$3)
+       SetTTFName(0x409,19,"-")
+endif
+Generate($2)