Definition at line 39 of file SegmentToDelta.php.
◆ __construct()
Object constructor
Parses the raw binary table data. Throws an exception if the table is malformed.
- Parameters
-
string | $cmapData | Raw binary cmap table data. |
- Exceptions
-
Definition at line 318 of file SegmentToDelta.php.
322 $actualLength = strlen($cmapData);
323 if ($actualLength < 23) {
324 #require_once 'Zend/Pdf/Exception.php'; 333 #require_once 'Zend/Pdf/Exception.php'; 339 if ($length != $actualLength) {
340 #require_once 'Zend/Pdf/Exception.php'; 341 throw new Zend_Pdf_Exception(
"Table length ($length) does not match actual length ($actualLength)",
351 if ($language != 0) {
359 $this->_segmentCount = $this->
_extractUInt2($cmapData, 6) >> 1;
360 $this->_searchRange = $this->
_extractUInt2($cmapData, 8) >> 1;
362 $this->_searchIterations = $this->
_extractUInt2($cmapData, 10) + 1;
366 $this->_segmentTableEndCodes[
$i] = $this->
_extractUInt2($cmapData, $offset);
374 $this->_segmentTableStartCodes[
$i] = $this->
_extractUInt2($cmapData, $offset);
378 $this->_segmentTableIdDeltas[
$i] = $this->
_extractInt2($cmapData, $offset);
386 $this->_segmentTableIdRangeOffsets[
$i] = $this->
_extractUInt2($cmapData, $offset) >> 1;
393 for (; $offset < $length; $offset += 2) {
394 $this->_glyphIndexArray[] = $this->
_extractUInt2($cmapData, $offset);
400 if ($offset != $length) {
401 #require_once 'Zend/Pdf/Exception.php'; 402 throw new Zend_Pdf_Exception(
"Ending offset ($offset) does not match length ($length)",
const CMAP_WRONG_TABLE_LENGTH
const CMAP_FINAL_OFFSET_NOT_LENGTH
const CMAP_TABLE_DATA_TOO_SMALL
_extractInt2(&$data, $index)
const TYPE_SEGMENT_TO_DELTA
const CMAP_WRONG_TABLE_TYPE
_extractUInt2(&$data, $index)
◆ getCoveredCharacters()
Returns an array containing the Unicode characters that have entries in this character map.
- Returns
- array Unicode character codes.
Definition at line 253 of file SegmentToDelta.php.
255 $characterCodes = array();
257 for (
$code = $this->_segmentTableStartCodes[
$i];
$code <= $this->_segmentTableEndCodes[
$i];
$code++) {
258 $characterCodes[] =
$code;
261 return $characterCodes;
◆ 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 276 of file SegmentToDelta.php.
278 $glyphNumbers = array();
281 if ($this->_segmentTableIdRangeOffsets[$segmentNum] == 0) {
282 $delta = $this->_segmentTableIdDeltas[$segmentNum];
284 for (
$code = $this->_segmentTableStartCodes[$segmentNum];
285 $code <= $this->_segmentTableEndCodes[$segmentNum];
287 $glyphNumbers[
$code] = (
$code + $delta) % 65536;
290 $code = $this->_segmentTableStartCodes[$segmentNum];
291 $glyphIndex = $this->_segmentTableIdRangeOffsets[$segmentNum] - ($this->_segmentCount - $segmentNum) - 1;
293 while ($code <= $this->_segmentTableEndCodes[$segmentNum]) {
294 $glyphNumbers[
$code] = $this->_glyphIndexArray[$glyphIndex];
302 return $glyphNumbers;
◆ 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 | $characterCode | Unicode character code (code point). |
- Returns
- integer Glyph number.
Definition at line 207 of file SegmentToDelta.php.
213 if ($characterCode > 0xffff) {
217 if ($this->_searchRangeEndCode >= $characterCode) {
224 if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
225 $subtableIndex = $searchIndex;
226 $searchIndex -= $this->_searchRange >>
$i;
228 $searchIndex += $this->_searchRange >>
$i;
232 if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
236 if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
237 $glyphNumber = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
239 $glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
240 $this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
242 $glyphNumber = $this->_glyphIndexArray[$glyphIndex];
const MISSING_CHARACTER_GLYPH
◆ 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 | $characterCodes | Array of Unicode character codes (code points). |
- Returns
- array Array of glyph numbers.
Definition at line 118 of file SegmentToDelta.php.
120 $glyphNumbers = array();
121 foreach ($characterCodes as $key => $characterCode) {
125 if ($characterCode > 0xffff) {
141 if ($this->_searchRangeEndCode >= $characterCode) {
153 if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
154 $subtableIndex = $searchIndex;
155 $searchIndex -= $this->_searchRange >>
$i;
157 $searchIndex += $this->_searchRange >>
$i;
164 if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
169 if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
173 $glyphNumbers[$key] = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
184 $glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
185 $this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
187 $glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
192 return $glyphNumbers;
const MISSING_CHARACTER_GLYPH
◆ $_glyphIndexArray
$_glyphIndexArray = array() |
|
protected |
◆ $_searchIterations
◆ $_searchRange
◆ $_searchRangeEndCode
◆ $_segmentCount
◆ $_segmentTableEndCodes
$_segmentTableEndCodes = array() |
|
protected |
◆ $_segmentTableIdDeltas
$_segmentTableIdDeltas = array() |
|
protected |
◆ $_segmentTableIdRangeOffsets
$_segmentTableIdRangeOffsets = array() |
|
protected |
◆ $_segmentTableStartCodes
$_segmentTableStartCodes = array() |
|
protected |
The documentation for this class was generated from the following file: