#!/usr/bin/php * @author Fabien Ménager * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License * @version $Id: load_font.php 467 2012-02-04 13:25:17Z fabien.menager $ */ require_once "dompdf_config.inc.php"; require_once "lib/php-font-lib/classes/font.cls.php"; /** * Display command line usage */ function usage() { echo << array("_Bold", "b", "B", "bd", "BD"), "italic" => array("_Italic", "i", "I"), "bold_italic" => array("_Bold_Italic", "bi", "BI", "ib", "IB"), ); foreach ($patterns as $type => $_patterns) { if ( !isset($$type) || !is_readable($$type) ) { foreach($_patterns as $_pattern) { if ( is_readable("$path$_pattern$ext") ) { $$type = "$path$_pattern$ext"; break; } } if ( is_null($$type) ) echo ("Unable to find $type face file.\n"); } } $fonts = compact("normal", "bold", "italic", "bold_italic"); $entry = array(); // Copy the files to the font directory. foreach ($fonts as $var => $src) { if ( is_null($src) ) { $entry[$var] = DOMPDF_FONT_DIR . mb_substr(basename($normal), 0, -4); continue; } // Verify that the fonts exist and are readable if ( !is_readable($src) ) throw new DOMPDF_Exception("Requested font '$src' is not readable"); $dest = DOMPDF_FONT_DIR . basename($src); if ( !is_writeable(dirname($dest)) ) throw new DOMPDF_Exception("Unable to write to destination '$dest'."); 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)); }