getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, '', ''); Zend_Pdf_Font::$_fontNames[$fontName] = $font; $filePathKey = md5($filePath); Zend_Pdf_Font::$_fontFilePaths[$filePathKey] = $font; return $font; } else { /* The type of font could not be determined. Give up. */ require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception("Cannot determine font type: $filePath", Zend_Pdf_Exception::CANT_DETERMINE_FONT_TYPE); } } /**** Internal Methods ****/ /* Font Extraction Methods */ /** * Attempts to extract a TrueType font from the data source. * * If the font parser throws an exception that suggests the data source * simply doesn't contain a TrueType font, catches it and returns null. If * an exception is thrown that suggests the TrueType font is corrupt or * otherwise unusable, throws that exception. If successful, returns the * font object. * * @param Zend_Pdf_FileParserDataSource $dataSource * @param integer $embeddingOptions Options for font embedding. * @return Zend_Pdf_Resource_Font_OpenType_TrueType May also return null if * the data source does not appear to contain a TrueType font. * @throws Zend_Pdf_Exception */ protected static function _extractTrueTypeFont($dataSource, $embeddingOptions) { try { require_once 'Zend/Pdf/FileParser/Font/OpenType/TrueType.php'; $fontParser = new Zend_Pdf_FileParser_Font_OpenType_TrueType($dataSource); $fontParser->parse(); if ($fontParser->isAdobeLatinSubset) { require_once 'Zend/Pdf/Resource/Font/Simple/Parsed/TrueType.php'; $font = new Zend_Pdf_Resource_Font_Simple_Parsed_TrueType($fontParser, $embeddingOptions); } else { require_once 'Zend/Pdf/Resource/Font/CidFont/TrueType.php'; require_once 'Zend/Pdf/Resource/Font/Type0.php'; /* Use Composite Type 0 font which supports Unicode character mapping */ $cidFont = new Zend_Pdf_Resource_Font_CidFont_TrueType($fontParser, $embeddingOptions); $font = new Zend_Pdf_Resource_Font_Type0($cidFont); } } catch (Zend_Pdf_Exception $exception) { /* The following exception codes suggest that this isn't really a * TrueType font. If we caught such an exception, simply return * null. For all other cases, it probably is a TrueType font but has * a problem; throw the exception again. */ $fontParser = null; require_once 'Zend/Pdf/Exception.php'; switch ($exception->getCode()) { case Zend_Pdf_Exception::WRONG_FONT_TYPE: // break intentionally omitted case Zend_Pdf_Exception::BAD_TABLE_COUNT: // break intentionally omitted case Zend_Pdf_Exception::BAD_MAGIC_NUMBER: return null; default: throw $exception; } } return $font; } }