echo "Copying {$src} to {$dest}...\n"; if (!copy($src, $dest)) { throw new DOMPDF_Exception("Unable to copy '{$src}' to '{$dest}'"); } $entry_name = mb_substr($dest, 0, -4); echo "Generating Adobe Font Metrics for {$entry_name}...\n"; $font_obj = Font::load($dest); $font_obj->saveAdobeFontMetrics("{$entry_name}.ufm"); $entry[$var] = $entry_name; } // Store the fonts in the lookup table Font_Metrics::set_font_family($fontname, $entry); // Save the changes Font_Metrics::save_font_families(); } // If installing system fonts (may take a long time) if ($_SERVER["argv"][1] === "system_fonts") { $fonts = Font_Metrics::get_system_fonts(); foreach ($fonts as $family => $files) { echo " >> Installing '{$family}'... \n"; if (!isset($files["normal"])) { echo "No 'normal' style font file\n"; } else { install_font_family($family, @$files["normal"], @$files["bold"], @$files["italic"], @$files["bold_italic"]); echo "Done !\n"; } echo "\n"; } } else { call_user_func_array("install_font_family", array_slice($_SERVER["argv"], 1)); }
$entry[$var] = $dest; } } else { throw new DOMPDF_Exception("Unable to process fonts of type '{$ext}'."); } // If the extension is a ttf, try and convert the fonts to afm too if (mb_strtolower($ext) === ".ttf" || strtolower($ext) == ".otf") { foreach ($fonts as $var => $font) { if (is_null($font)) { $entry[$var] = DOMPDF_FONT_DIR . mb_substr(basename($normal), 0, -4); continue; } $dest = DOMPDF_FONT_DIR . mb_substr(basename($font), 0, -4); echo "Generating .afm for {$font}...\n"; echo "Command: " . _TTF2AFM . " " . escapeshellarg($font) . " " . escapeshellarg($dest) . "\n"; exec(_TTF2AFM . " " . escapeshellarg($font) . " " . escapeshellarg($dest) . " &> /dev/null", $output, $ret); $entry[$var] = $dest; } } // FIXME: how to generate afms from pfb? // Store the fonts in the lookup table Font_Metrics::set_font_family(strtolower($fontname), $entry); // Save the changes Font_Metrics::save_font_families(); } $normal = $_SERVER["argv"][2]; $bold = isset($_SERVER["argv"][3]) ? $_SERVER["argv"][3] : null; $italic = isset($_SERVER["argv"][4]) ? $_SERVER["argv"][4] : null; $bold_italic = isset($_SERVER["argv"][5]) ? $_SERVER["argv"][5] : null; install_font_family($_SERVER["argv"][1], $normal, $bold, $italic, $bold_italic);