Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Type0.php
Go to the documentation of this file.
1 <?php
25 #require_once 'Zend/Pdf/Element/Array.php';
26 #require_once 'Zend/Pdf/Element/Name.php';
27 
28 
30 #require_once 'Zend/Pdf/Resource/Font.php';
31 
64 {
70  private $_descendantFont;
71 
72 
78  static private function getToUnicodeCMapData()
79  {
80  return '/CIDInit /ProcSet findresource begin ' . "\n"
81  . '12 dict begin ' . "\n"
82  . 'begincmap ' . "\n"
83  . '/CIDSystemInfo ' . "\n"
84  . '<</Registry (Adobe) ' . "\n"
85  . '/Ordering (UCS) ' . "\n"
86  . '/Supplement 0' . "\n"
87  . '>> def' . "\n"
88  . '/CMapName /Adobe-Identity-UCS def ' . "\n"
89  . '/CMapType 2 def ' . "\n"
90  . '1 begincodespacerange' . "\n"
91  . '<0000> <FFFF> ' . "\n"
92  . 'endcodespacerange ' . "\n"
93  . '1 beginbfrange ' . "\n"
94  . '<0000> <FFFF> <0000> ' . "\n"
95  . 'endbfrange ' . "\n"
96  . 'endcmap ' . "\n"
97  . 'CMapName currentdict /CMap defineresource pop ' . "\n"
98  . 'end '
99  . 'end ';
100  }
101 
106  public function __construct(Zend_Pdf_Resource_Font_CidFont $descendantFont)
107  {
108  parent::__construct();
109 
110  $this->_objectFactory->attach($descendantFont->getFactory());
111 
112  $this->_fontType = Zend_Pdf_Font::TYPE_TYPE_0;
113  $this->_descendantFont = $descendantFont;
114 
115 
116  $this->_fontNames = $descendantFont->getFontNames();
117 
118  $this->_isBold = $descendantFont->isBold();
119  $this->_isItalic = $descendantFont->isItalic();
120  $this->_isMonospaced = $descendantFont->isMonospace();
121 
122  $this->_underlinePosition = $descendantFont->getUnderlinePosition();
123  $this->_underlineThickness = $descendantFont->getUnderlineThickness();
124  $this->_strikePosition = $descendantFont->getStrikePosition();
125  $this->_strikeThickness = $descendantFont->getStrikeThickness();
126 
127  $this->_unitsPerEm = $descendantFont->getUnitsPerEm();
128 
129  $this->_ascent = $descendantFont->getAscent();
130  $this->_descent = $descendantFont->getDescent();
131  $this->_lineGap = $descendantFont->getLineGap();
132 
133 
134  $this->_resource->Subtype = new Zend_Pdf_Element_Name('Type0');
135  $this->_resource->BaseFont = new Zend_Pdf_Element_Name($descendantFont->getResource()->BaseFont->value);
136  $this->_resource->DescendantFonts = new Zend_Pdf_Element_Array(array( $descendantFont->getResource() ));
137  $this->_resource->Encoding = new Zend_Pdf_Element_Name('Identity-H');
138 
139  $toUnicode = $this->_objectFactory->newStreamObject(self::getToUnicodeCMapData());
140  $this->_resource->ToUnicode = $toUnicode;
141 
142  }
143 
155  public function glyphNumbersForCharacters($characterCodes)
156  {
157  return $characterCodes;
158  }
159 
169  public function glyphNumberForCharacter($characterCode)
170  {
171  return $characterCode;
172  }
173 
192  public function getCoveredPercentage($string, $charEncoding = '')
193  {
194  return $this->_descendantFont->getCoveredPercentage($string, $charEncoding);
195  }
196 
211  public function widthsForGlyphs($glyphNumbers)
212  {
213  return $this->_descendantFont->widthsForChars($glyphNumbers);
214  }
215 
225  public function widthForGlyph($glyphNumber)
226  {
227  return $this->_descendantFont->widthForChar($glyphNumber);
228  }
229 
239  public function encodeString($string, $charEncoding)
240  {
241  return iconv($charEncoding, 'UTF-16BE', $string);
242  }
243 
253  public function decodeString($string, $charEncoding)
254  {
255  return iconv('UTF-16BE', $charEncoding, $string);
256  }
257 }
encodeString($string, $charEncoding)
Definition: Type0.php:239
widthForGlyph($glyphNumber)
Definition: Type0.php:225
getCoveredPercentage($string, $charEncoding='')
Definition: Type0.php:192
glyphNumberForCharacter($characterCode)
Definition: Type0.php:169
__construct(Zend_Pdf_Resource_Font_CidFont $descendantFont)
Definition: Type0.php:106
const TYPE_TYPE_0
Definition: Font.php:69
decodeString($string, $charEncoding)
Definition: Type0.php:253
widthsForGlyphs($glyphNumbers)
Definition: Type0.php:211
glyphNumbersForCharacters($characterCodes)
Definition: Type0.php:155