24 #require_once 'Zend/Pdf/Cmap.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;
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];
255 $characterCodes = array();
257 for (
$code = $this->_segmentTableStartCodes[
$i];
$code <= $this->_segmentTableEndCodes[
$i];
$code++) {
258 $characterCodes[] =
$code;
261 return $characterCodes;
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;
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)",
glyphNumberForCharacter($characterCode)
const CMAP_WRONG_TABLE_LENGTH
const CMAP_FINAL_OFFSET_NOT_LENGTH
const CMAP_TABLE_DATA_TOO_SMALL
glyphNumbersForCharacters($characterCodes)
_extractInt2(&$data, $index)
const TYPE_SEGMENT_TO_DELTA
const CMAP_WRONG_TABLE_TYPE
const MISSING_CHARACTER_GLYPH
getCoveredCharactersGlyphs()
_extractUInt2(&$data, $index)
$_segmentTableIdRangeOffsets