File indexing completed on 2025-01-19 05:21:23
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Pdf 0017 * @subpackage Fonts 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 0024 /** Internally used classes */ 0025 // require_once 'Zend/Pdf/Element/Array.php'; 0026 // require_once 'Zend/Pdf/Element/Name.php'; 0027 // require_once 'Zend/Pdf/Element/Numeric.php'; 0028 0029 0030 /** Zend_Pdf_Resource_Font_Simple */ 0031 // require_once 'Zend/Pdf/Resource/Font/Simple.php'; 0032 0033 /** 0034 * Parsed and (optionaly) embedded fonts implementation 0035 * 0036 * OpenType fonts can contain either TrueType or PostScript Type 1 outlines. 0037 * 0038 * @package Zend_Pdf 0039 * @subpackage Fonts 0040 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0041 * @license http://framework.zend.com/license/new-bsd New BSD License 0042 */ 0043 abstract class Zend_Pdf_Resource_Font_Simple_Parsed extends Zend_Pdf_Resource_Font_Simple 0044 { 0045 /** 0046 * Object constructor 0047 * 0048 * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing OpenType file. 0049 * @throws Zend_Pdf_Exception 0050 */ 0051 public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser) 0052 { 0053 parent::__construct(); 0054 0055 0056 $fontParser->parse(); 0057 0058 /* Object properties */ 0059 0060 $this->_fontNames = $fontParser->names; 0061 0062 $this->_isBold = $fontParser->isBold; 0063 $this->_isItalic = $fontParser->isItalic; 0064 $this->_isMonospaced = $fontParser->isMonospaced; 0065 0066 $this->_underlinePosition = $fontParser->underlinePosition; 0067 $this->_underlineThickness = $fontParser->underlineThickness; 0068 $this->_strikePosition = $fontParser->strikePosition; 0069 $this->_strikeThickness = $fontParser->strikeThickness; 0070 0071 $this->_unitsPerEm = $fontParser->unitsPerEm; 0072 0073 $this->_ascent = $fontParser->ascent; 0074 $this->_descent = $fontParser->descent; 0075 $this->_lineGap = $fontParser->lineGap; 0076 0077 $this->_glyphWidths = $fontParser->glyphWidths; 0078 $this->_missingGlyphWidth = $this->_glyphWidths[0]; 0079 0080 0081 $this->_cmap = $fontParser->cmap; 0082 0083 0084 /* Resource dictionary */ 0085 0086 $baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8'); 0087 $this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont); 0088 0089 $this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0); 0090 $this->_resource->LastChar = new Zend_Pdf_Element_Numeric(count($this->_glyphWidths) - 1); 0091 0092 /* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects. 0093 */ 0094 $pdfWidths = array(); 0095 foreach ($this->_glyphWidths as $width) { 0096 $pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width)); 0097 } 0098 /* Create the Zend_Pdf_Element_Array object and add it to the font's 0099 * object factory and resource dictionary. 0100 */ 0101 $widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths); 0102 $widthsObject = $this->_objectFactory->newObject($widthsArrayElement); 0103 $this->_resource->Widths = $widthsObject; 0104 } 0105 }