From 1cc7d4fa61c2a2cd5e93e41efcf3e3efd329a921 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 19 Apr 2023 12:30:56 +0200 Subject: [PATCH] wait #5870 @0.75 --- app/Jobs/FluidbookCompiler.php | 32 ++++++++++++++++++++---------- resources/tools/fonts/convertrn.pe | 27 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 resources/tools/fonts/convertrn.pe diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 42844d725..456abf830 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -3516,37 +3516,49 @@ height="0" width="0" style="display:none;visibility:hidden"> { $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 index 000000000..2423bae5a --- /dev/null +++ b/resources/tools/fonts/convertrn.pe @@ -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) -- 2.39.5