Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cmap.php
Go to the documentation of this file.
1 <?php
53 abstract class Zend_Pdf_Cmap
54 {
55  /**** Class Constants ****/
56 
57 
58  /* Cmap Table Types */
59 
63  const TYPE_BYTE_ENCODING = 0x00;
64 
68  const TYPE_HIGH_BYTE_MAPPING = 0x02;
69 
73  const TYPE_SEGMENT_TO_DELTA = 0x04;
74 
78  const TYPE_TRIMMED_TABLE = 0x06;
79 
83  const TYPE_MIXED_COVERAGE = 0x08;
84 
88  const TYPE_TRIMMED_ARRAY = 0x0a;
89 
94 
100 
104  const TYPE_UNKNOWN = 0xff;
105 
106 
107  /* Special Glyph Names */
108 
113 
114 
115 
116  /**** Public Interface ****/
117 
118 
119  /* Factory Methods */
120 
145  public static function cmapWithTypeData($cmapType, $cmapData)
146  {
147  switch ($cmapType) {
149  #require_once 'Zend/Pdf/Cmap/ByteEncoding.php';
150  return new Zend_Pdf_Cmap_ByteEncoding($cmapData);
151 
153  #require_once 'Zend/Pdf/Cmap/ByteEncoding/Static.php';
154  return new Zend_Pdf_Cmap_ByteEncoding_Static($cmapData);
155 
157  #require_once 'Zend/Pdf/Exception.php';
158  throw new Zend_Pdf_Exception('High byte mapping cmap currently unsupported',
160 
162  #require_once 'Zend/Pdf/Cmap/SegmentToDelta.php';
163  return new Zend_Pdf_Cmap_SegmentToDelta($cmapData);
164 
166  #require_once 'Zend/Pdf/Cmap/TrimmedTable.php';
167  return new Zend_Pdf_Cmap_TrimmedTable($cmapData);
168 
170  #require_once 'Zend/Pdf/Exception.php';
171  throw new Zend_Pdf_Exception('Mixed coverage cmap currently unsupported',
173 
175  #require_once 'Zend/Pdf/Exception.php';
176  throw new Zend_Pdf_Exception('Trimmed array cmap currently unsupported',
178 
180  #require_once 'Zend/Pdf/Exception.php';
181  throw new Zend_Pdf_Exception('Segmented coverage cmap currently unsupported',
183 
184  default:
185  #require_once 'Zend/Pdf/Exception.php';
186  throw new Zend_Pdf_Exception("Unknown cmap type: $cmapType",
188  }
189  }
190 
191 
192  /* Abstract Methods */
193 
203  abstract public function __construct($cmapData);
204 
216  abstract public function glyphNumbersForCharacters($characterCodes);
217 
230  abstract public function glyphNumberForCharacter($characterCode);
231 
238  abstract public function getCoveredCharacters();
239 
251  abstract public function getCoveredCharactersGlyphs();
252 
253 
254  /**** Internal Methods ****/
255 
256 
257  /* Internal Utility Methods */
258 
270  protected function _extractInt2(&$data, $index)
271  {
272  if (($index < 0) | (($index + 1) > strlen($data))) {
273  #require_once 'Zend/Pdf/Exception.php';
274  throw new Zend_Pdf_Exception("Index out of range: $index",
276  }
277  $number = ord($data[$index]);
278  if (($number & 0x80) == 0x80) { // negative
279  $number = ~((((~ $number) & 0xff) << 8) | ((~ ord($data[++$index])) & 0xff));
280  } else {
281  $number = ($number << 8) | ord($data[++$index]);
282  }
283  return $number;
284  }
285 
297  protected function _extractUInt2(&$data, $index)
298  {
299  if (($index < 0) | (($index + 1) > strlen($data))) {
300  #require_once 'Zend/Pdf/Exception.php';
301  throw new Zend_Pdf_Exception("Index out of range: $index",
303  }
304  $number = (ord($data[$index]) << 8) | ord($data[++$index]);
305  return $number;
306  }
307 
324  protected function _extractUInt4(&$data, $index)
325  {
326  if (($index < 0) | (($index + 3) > strlen($data))) {
327  #require_once 'Zend/Pdf/Exception.php';
328  throw new Zend_Pdf_Exception("Index out of range: $index",
330  }
331  $number = (ord($data[$index]) << 24) | (ord($data[++$index]) << 16) |
332  (ord($data[++$index]) << 8) | ord($data[++$index]);
333  return $number;
334  }
335 
336 }
_extractUInt4(&$data, $index)
Definition: Cmap.php:324
const TYPE_UNKNOWN
Definition: Cmap.php:104
$number
Definition: details.phtml:22
const TYPE_MIXED_COVERAGE
Definition: Cmap.php:83
const INDEX_OUT_OF_RANGE
Definition: Exception.php:100
const TYPE_BYTE_ENCODING
Definition: Cmap.php:63
const TYPE_TRIMMED_TABLE
Definition: Cmap.php:78
_extractInt2(&$data, $index)
Definition: Cmap.php:270
const TYPE_SEGMENTED_COVERAGE
Definition: Cmap.php:93
const TYPE_BYTE_ENCODING_STATIC
Definition: Cmap.php:99
getCoveredCharactersGlyphs()
static cmapWithTypeData($cmapType, $cmapData)
Definition: Cmap.php:145
__construct($cmapData)
glyphNumbersForCharacters($characterCodes)
const TYPE_SEGMENT_TO_DELTA
Definition: Cmap.php:73
const MISSING_CHARACTER_GLYPH
Definition: Cmap.php:112
const TYPE_TRIMMED_ARRAY
Definition: Cmap.php:88
_extractUInt2(&$data, $index)
Definition: Cmap.php:297
const TYPE_HIGH_BYTE_MAPPING
Definition: Cmap.php:68
$index
Definition: list.phtml:44
const CMAP_TYPE_UNSUPPORTED
Definition: Exception.php:255
glyphNumberForCharacter($characterCode)