Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Pdf_Cmap_TrimmedTable Class Reference
Inheritance diagram for Zend_Pdf_Cmap_TrimmedTable:
Zend_Pdf_Cmap

Public Member Functions

 glyphNumbersForCharacters ($characterCodes)
 
 glyphNumberForCharacter ($characterCode)
 
 getCoveredCharacters ()
 
 getCoveredCharactersGlyphs ()
 
 __construct ($cmapData)
 
- Public Member Functions inherited from Zend_Pdf_Cmap
 __construct ($cmapData)
 
 glyphNumbersForCharacters ($characterCodes)
 
 glyphNumberForCharacter ($characterCode)
 
 getCoveredCharacters ()
 
 getCoveredCharactersGlyphs ()
 

Protected Attributes

 $_startCode = 0
 
 $_endCode = 0
 
 $_glyphIndexArray = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Pdf_Cmap
static cmapWithTypeData ($cmapType, $cmapData)
 
- Data Fields inherited from Zend_Pdf_Cmap
const TYPE_BYTE_ENCODING = 0x00
 
const TYPE_HIGH_BYTE_MAPPING = 0x02
 
const TYPE_SEGMENT_TO_DELTA = 0x04
 
const TYPE_TRIMMED_TABLE = 0x06
 
const TYPE_MIXED_COVERAGE = 0x08
 
const TYPE_TRIMMED_ARRAY = 0x0a
 
const TYPE_SEGMENTED_COVERAGE = 0x0c
 
const TYPE_BYTE_ENCODING_STATIC = 0xf1
 
const TYPE_UNKNOWN = 0xff
 
const MISSING_CHARACTER_GLYPH = 0x00
 
- Protected Member Functions inherited from Zend_Pdf_Cmap
 _extractInt2 (&$data, $index)
 
 _extractUInt2 (&$data, $index)
 
 _extractUInt4 (&$data, $index)
 

Detailed Description

Definition at line 39 of file TrimmedTable.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $cmapData)

Object constructor

Parses the raw binary table data. Throws an exception if the table is malformed.

Parameters
string$cmapDataRaw binary cmap table data.
Exceptions
Zend_Pdf_Exception

Definition at line 167 of file TrimmedTable.php.

168  {
169  /* Sanity check: The table should be at least 9 bytes in size.
170  */
171  $actualLength = strlen($cmapData);
172  if ($actualLength < 9) {
173  #require_once 'Zend/Pdf/Exception.php';
174  throw new Zend_Pdf_Exception('Insufficient table data',
176  }
177 
178  /* Sanity check: Make sure this is right data for this table type.
179  */
180  $type = $this->_extractUInt2($cmapData, 0);
182  #require_once 'Zend/Pdf/Exception.php';
183  throw new Zend_Pdf_Exception('Wrong cmap table type',
185  }
186 
187  $length = $this->_extractUInt2($cmapData, 2);
188  if ($length != $actualLength) {
189  #require_once 'Zend/Pdf/Exception.php';
190  throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
192  }
193 
194  /* Mapping tables should be language-independent. The font may not work
195  * as expected if they are not. Unfortunately, many font files in the
196  * wild incorrectly record a language ID in this field, so we can't
197  * call this a failure.
198  */
199  $language = $this->_extractUInt2($cmapData, 4);
200  if ($language != 0) {
201  // Record a warning here somehow?
202  }
203 
204  $this->_startCode = $this->_extractUInt2($cmapData, 6);
205 
206  $entryCount = $this->_extractUInt2($cmapData, 8);
207  $expectedCount = ($length - 10) >> 1;
208  if ($entryCount != $expectedCount) {
209  #require_once 'Zend/Pdf/Exception.php';
210  throw new Zend_Pdf_Exception("Entry count is wrong; expected: $expectedCount; actual: $entryCount",
212  }
213 
214  $this->_endCode = $this->_startCode + $entryCount - 1;
215 
216  $offset = 10;
217  for ($i = 0; $i < $entryCount; $i++, $offset += 2) {
218  $this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
219  }
220 
221  /* Sanity check: After reading all of the data, we should be at the end
222  * of the table.
223  */
224  if ($offset != $length) {
225  #require_once 'Zend/Pdf/Exception.php';
226  throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
228  }
229  }
const CMAP_WRONG_TABLE_LENGTH
Definition: Exception.php:275
const CMAP_FINAL_OFFSET_NOT_LENGTH
Definition: Exception.php:287
const CMAP_WRONG_ENTRY_COUNT
Definition: Exception.php:292
const CMAP_TABLE_DATA_TOO_SMALL
Definition: Exception.php:265
const TYPE_TRIMMED_TABLE
Definition: Cmap.php:78
$type
Definition: item.phtml:13
const CMAP_WRONG_TABLE_TYPE
Definition: Exception.php:270
_extractUInt2(&$data, $index)
Definition: Cmap.php:297
$i
Definition: gallery.phtml:31

Member Function Documentation

◆ getCoveredCharacters()

getCoveredCharacters ( )

Returns an array containing the Unicode characters that have entries in this character map.

Returns
array Unicode character codes.

Definition at line 124 of file TrimmedTable.php.

125  {
126  $characterCodes = array();
127  for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
128  $characterCodes[] = $code;
129  }
130  return $characterCodes;
131  }
$code
Definition: info.phtml:12

◆ getCoveredCharactersGlyphs()

getCoveredCharactersGlyphs ( )

Returns an array containing the glyphs numbers that have entries in this character map. Keys are Unicode character codes (integers)

This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters()) call, but this method do it in more effective way (prepare complete list instead of searching glyph for each character code).

Definition at line 145 of file TrimmedTable.php.

146  {
147  $glyphNumbers = array();
148  for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
149  $glyphNumbers[$code] = $this->_glyphIndexArray[$code - $this->_startCode];
150  }
151 
152  return $glyphNumbers;
153  }
$code
Definition: info.phtml:12

◆ glyphNumberForCharacter()

glyphNumberForCharacter (   $characterCode)

Returns the glyph number corresponding to the Unicode character.

If a particular character doesn't exist in this font, the special 'missing character glyph' will be substituted.

See also glyphNumbersForCharacters() which is optimized for bulk operations.

Parameters
integer$characterCodeUnicode character code (code point).
Returns
integer Glyph number.

Definition at line 109 of file TrimmedTable.php.

110  {
111  if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
113  }
114  $glyphIndex = $characterCode - $this->_startCode;
115  return $this->_glyphIndexArray[$glyphIndex];
116  }
const MISSING_CHARACTER_GLYPH
Definition: Cmap.php:112

◆ glyphNumbersForCharacters()

glyphNumbersForCharacters (   $characterCodes)

Returns an array of glyph numbers corresponding to the Unicode characters.

If a particular character doesn't exist in this font, the special 'missing character glyph' will be substituted.

See also glyphNumberForCharacter().

Parameters
array$characterCodesArray of Unicode character codes (code points).
Returns
array Array of glyph numbers.

Definition at line 80 of file TrimmedTable.php.

81  {
82  $glyphNumbers = array();
83  foreach ($characterCodes as $key => $characterCode) {
84 
85  if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
86  $glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
87  continue;
88  }
89 
90  $glyphIndex = $characterCode - $this->_startCode;
91  $glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
92 
93  }
94  return $glyphNumbers;
95  }
const MISSING_CHARACTER_GLYPH
Definition: Cmap.php:112

Field Documentation

◆ $_endCode

$_endCode = 0
protected

Definition at line 54 of file TrimmedTable.php.

◆ $_glyphIndexArray

$_glyphIndexArray = array()
protected

Definition at line 60 of file TrimmedTable.php.

◆ $_startCode

$_startCode = 0
protected

Definition at line 48 of file TrimmedTable.php.


The documentation for this class was generated from the following file: