|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Pdf |
|
17 * @subpackage Fonts |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: Parsed.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 |
|
24 /** Internally used classes */ |
|
25 require_once 'Zend/Pdf/Element/Array.php'; |
|
26 require_once 'Zend/Pdf/Element/Name.php'; |
|
27 require_once 'Zend/Pdf/Element/Numeric.php'; |
|
28 |
|
29 |
|
30 /** Zend_Pdf_Resource_Font_Simple */ |
|
31 require_once 'Zend/Pdf/Resource/Font/Simple.php'; |
|
32 |
|
33 /** |
|
34 * Parsed and (optionaly) embedded fonts implementation |
|
35 * |
|
36 * OpenType fonts can contain either TrueType or PostScript Type 1 outlines. |
|
37 * |
|
38 * @package Zend_Pdf |
|
39 * @subpackage Fonts |
|
40 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
41 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
42 */ |
|
43 abstract class Zend_Pdf_Resource_Font_Simple_Parsed extends Zend_Pdf_Resource_Font_Simple |
|
44 { |
|
45 /** |
|
46 * Object constructor |
|
47 * |
|
48 * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing OpenType file. |
|
49 * @throws Zend_Pdf_Exception |
|
50 */ |
|
51 public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser) |
|
52 { |
|
53 parent::__construct(); |
|
54 |
|
55 |
|
56 $fontParser->parse(); |
|
57 |
|
58 /* Object properties */ |
|
59 |
|
60 $this->_fontNames = $fontParser->names; |
|
61 |
|
62 $this->_isBold = $fontParser->isBold; |
|
63 $this->_isItalic = $fontParser->isItalic; |
|
64 $this->_isMonospaced = $fontParser->isMonospaced; |
|
65 |
|
66 $this->_underlinePosition = $fontParser->underlinePosition; |
|
67 $this->_underlineThickness = $fontParser->underlineThickness; |
|
68 $this->_strikePosition = $fontParser->strikePosition; |
|
69 $this->_strikeThickness = $fontParser->strikeThickness; |
|
70 |
|
71 $this->_unitsPerEm = $fontParser->unitsPerEm; |
|
72 |
|
73 $this->_ascent = $fontParser->ascent; |
|
74 $this->_descent = $fontParser->descent; |
|
75 $this->_lineGap = $fontParser->lineGap; |
|
76 |
|
77 $this->_glyphWidths = $fontParser->glyphWidths; |
|
78 $this->_missingGlyphWidth = $this->_glyphWidths[0]; |
|
79 |
|
80 |
|
81 $this->_cmap = $fontParser->cmap; |
|
82 |
|
83 |
|
84 /* Resource dictionary */ |
|
85 |
|
86 $baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8'); |
|
87 $this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont); |
|
88 |
|
89 $this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0); |
|
90 $this->_resource->LastChar = new Zend_Pdf_Element_Numeric(count($this->_glyphWidths) - 1); |
|
91 |
|
92 /* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects. |
|
93 */ |
|
94 $pdfWidths = array(); |
|
95 foreach ($this->_glyphWidths as $width) { |
|
96 $pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width)); |
|
97 } |
|
98 /* Create the Zend_Pdf_Element_Array object and add it to the font's |
|
99 * object factory and resource dictionary. |
|
100 */ |
|
101 $widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths); |
|
102 $widthsObject = $this->_objectFactory->newObject($widthsArrayElement); |
|
103 $this->_resource->Widths = $widthsObject; |
|
104 } |
|
105 } |