#!/usr/bin/php * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library in the file LICENSE.LGPL; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * * Alternatively, you may distribute this software under the terms of the * PHP License, version 3.0 or later. A copy of this license should have * been distributed with this file in the file LICENSE.PHP . If this is not * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. * * The latest version of DOMPDF might be available at: * http://www.digitaljunkies.ca/dompdf * * @link http://www.digitaljunkies.ca/dompdf * @copyright 2004 Benj Carson * @author Benj Carson * @package dompdf * @version 0.5.1 */ require_once("dompdf_config.inc.php"); /** * @access private */ define("_TTF2AFM", TTF2AFM . " -a -GAef -OW "); if ( !file_exists(TTF2AFM) ) { die("Unable to locate the ttf2afm / ttf2pt1 executable (checked " . TTF2AFM . ").\n"); } /** * Display command line usage * */ function usage() { echo << $src) { if ( is_null($src) ) { $entry[$var] = DOMPDF_FONT_DIR . basename($normal); continue; } // Verify that the fonts exist and are readable if ( !is_readable($src) ) throw new User_DOMPDF_Exception("Requested font '$pathname' is not readable"); $dest = DOMPDF_FONT_DIR . basename($src); if ( !is_writeable(dirname($dest)) ) throw new User_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 '" . DOMPDF_FONT_DIR . "$dest'."); $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") { 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"; exec( _TTF2AFM . " " . escapeshellarg($font) . " " . $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(mb_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); ?>