Font_Table_Directory_Entry

Generic Font table directory entry.

Defined (1)

The class is defined in the following location(s).

/lib/dompdf/lib/php-font-lib/classes/Font_Table_Directory_Entry.php  
  1. class Font_Table_Directory_Entry extends Font_Binary_Stream { 
  2. /** 
  3. * @var Font_TrueType 
  4. */ 
  5. protected $font; 
  6.  
  7. /** 
  8. * @var Font_Table 
  9. */ 
  10. protected $font_table; 
  11.  
  12. public $entryLength = 4; 
  13.  
  14. public $tag; 
  15. public $checksum; 
  16. public $offset; 
  17. public $length; 
  18.  
  19. protected $origF; 
  20.  
  21. static function computeChecksum($data) { 
  22. $len = strlen($data); 
  23. $mod = $len % 4; 
  24.  
  25. if ($mod) {  
  26. $data = str_pad($data, $len + (4 - $mod), "\0"); 
  27.  
  28. $len = strlen($data); 
  29.  
  30. $hi = 0x0000; 
  31. $lo = 0x0000; 
  32.  
  33. for ($i = 0; $i < $len; $i += 4) { 
  34. $hi += (ord($data[$i] ) << 8) + ord($data[$i+1]); 
  35. $lo += (ord($data[$i+2]) << 8) + ord($data[$i+3]); 
  36. $hi += $lo >> 16; 
  37. $lo = $lo & 0xFFFF; 
  38. $hi = $hi & 0xFFFF; 
  39.  
  40. return ($hi << 8) + $lo; 
  41.  
  42. function __construct(Font_TrueType $font) { 
  43. $this->font = $font; 
  44. $this->f = $font->f; 
  45.  
  46. function parse() { 
  47. $this->tag = $this->font->read(4); 
  48.  
  49. function open($filename, $mode = self::modeRead) { 
  50. // void 
  51.  
  52. function setTable(Font_Table $font_table) { 
  53. $this->font_table = $font_table; 
  54.  
  55. function encode($entry_offset) { 
  56. Font::d("\n==== $this->tag ===="); 
  57. //Font::d("Entry offset = $entry_offset"); 
  58.  
  59. $data = $this->font_table; 
  60. $font = $this->font; 
  61.  
  62. $table_offset = $font->pos(); 
  63. $this->offset = $table_offset; 
  64. $table_length = $data->encode(); 
  65.  
  66. $font->seek($table_offset); 
  67. $table_data = $font->read($table_length); 
  68.  
  69. $font->seek($entry_offset); 
  70.  
  71. $font->write($this->tag, 4); 
  72. $font->writeUInt32(self::computeChecksum($table_data)); 
  73. $font->writeUInt32($table_offset); 
  74. $font->writeUInt32($table_length); 
  75.  
  76. Font::d("Bytes written = $table_length"); 
  77.  
  78. $font->seek($table_offset + $table_length); 
  79.  
  80. /** 
  81. * @return Font_TrueType 
  82. */ 
  83. function getFont() { 
  84. return $this->font; 
  85.  
  86. function startRead() { 
  87. $this->font->seek($this->offset); 
  88.  
  89. function endRead() { 
  90. // 
  91.  
  92. function startWrite() { 
  93. $this->font->seek($this->offset); 
  94.  
  95. function endWrite() { 
  96. //