| @@ -361,8 +361,63 @@ | ||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | + // 'POST' table for un-mapped arabic glyphs | |
| 366 | + if (isset($this->tables['post'])) { | |
| 367 | + $this->seek_table("post"); | |
| 368 | + // Only works on Format 2.0 | |
| 369 | + $formata = $this->read_ushort(); | |
| 370 | + $formatb = $this->read_ushort(); | |
| 371 | + if ($formata == 2 && $formatb == 0) { | |
| 372 | + $this->skip(28); | |
| 373 | + $nGlyfs = $this->read_ushort(); | |
| 374 | + $glyphNameIndex = array(); | |
| 375 | + for ($i=0; $i<$nGlyfs; $i++) { | |
| 376 | + $glyphNameIndex[($this->read_ushort())] = $i; | |
| 377 | + } | |
| 378 | + | |
| 379 | + $opost = $this->get_table('post'); | |
| 380 | + $ptr = 34+($nGlyfs*2); | |
| 381 | + for ($i=0; $i<$nGlyfs; $i++) { | |
| 382 | + $len = ord(substr($opost,$ptr,1)); | |
| 383 | + $ptr++; | |
| 384 | + $name = substr($opost,$ptr,$len); | |
| 385 | + $gid = $glyphNameIndex[$i+258]; | |
| 386 | + // Select uni0600.xxx(x) - uni06FF.xxx(x) | |
| 387 | + if (preg_match('/^uni(06[0-9a-f]{2})\.(fina|medi|init|fin|med|ini)$/i',$name,$m)) { | |
| 388 | + if (!isset($glyphToChar[$gid]) || (isset($glyphToChar[$gid]) && is_array($glyphToChar[$gid]) && count($glyphToChar[$gid])==1 && $glyphToChar[$gid][0]>57343 && $glyphToChar[$gid][0]<63489)) { // if set in PUA private use area E000-F8FF, or NOT Unicode mapped | |
| 389 | + $uni = hexdec($m[1]); | |
| 390 | + $form = strtoupper(substr($m[2],0,1)); | |
| 391 | + // Assign new PUA Unicode between F500 - F7FF | |
| 392 | + $bit = $uni & 0xFF; | |
| 393 | + if ($form == 'I') { $bit += 0xF600; } | |
| 394 | + else if ($form == 'M') { $bit += 0xF700; } | |
| 395 | + else { $bit += 0xF500; } | |
| 396 | + $unAGlyphs .= $gid; | |
| 397 | + $name = 'uni'.strtoupper($m[1]).'.'.strtolower($m[2]); | |
| 398 | + $unAGlyphs .= ' : '.$name; | |
| 399 | + $unihexstr = $m[1]; | |
| 400 | + $unAGlyphs .= ' : '.$unihexstr; | |
| 401 | + $unAGlyphs .= ' : '.$uni; | |
| 402 | + $unAGlyphs .= ' : '.$form; | |
| 403 | + // if already set in PUA private use area E000-F8FF | |
| 404 | + if (isset($glyphToChar[$gid]) && $glyphToChar[$gid][0]>57343 && $glyphToChar[$gid][0]<63489) { | |
| 405 | + $unAGlyphs .= ' : '.$glyphToChar[$gid][0].' {'.dechex($glyphToChar[$gid][0]).'}'; | |
| 406 | + } | |
| 407 | + //else $unAGlyphs .= ':'; | |
| 408 | + $unAGlyphs .= ' : '.strtoupper(dechex($bit)); | |
| 409 | + $unAGlyphs .= '<br />'; | |
| 410 | + } | |
| 411 | + } | |
| 412 | + $ptr += $len; | |
| 413 | + } | |
| 414 | + if ($unAGlyphs) { | |
| 415 | + $unAGlyphs = 'GID:Name:Unicode base Hex:Dec:Form:PUA Unicode<br />'.$unAGlyphs ; | |
| 416 | + } | |
| 417 | + } | |
| 418 | + } | |
| 419 | + | |
| 365 | 420 | |
| 366 | 421 | |
| 367 | 422 | $bold = false; |
| 368 | 423 | $italic = false; |