Font_Table_name

`name` font table.

Defined (1)

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

/lib/dompdf/lib/php-font-lib/classes/Font_Table_name.php  
  1. class Font_Table_name extends Font_Table { 
  2. private static $header_format = array( 
  3. "format" => self::uint16,  
  4. "count" => self::uint16,  
  5. "stringOffset" => self::uint16,  
  6. ); 
  7.  
  8. const NAME_COPYRIGHT = 0; 
  9. const NAME_NAME = 1; 
  10. const NAME_SUBFAMILY = 2; 
  11. const NAME_SUBFAMILY_ID = 3; 
  12. const NAME_FULL_NAME = 4; 
  13. const NAME_VERSION = 5; 
  14. const NAME_POSTSCRIPT_NAME = 6; 
  15. const NAME_TRADEMARK = 7; 
  16. const NAME_MANUFACTURER = 8; 
  17. const NAME_DESIGNER = 9; 
  18. const NAME_DESCRIPTION = 10; 
  19. const NAME_VENDOR_URL = 11; 
  20. const NAME_DESIGNER_URL = 12; 
  21. const NAME_LICENSE = 13; 
  22. const NAME_LICENSE_URL = 14; 
  23. const NAME_PREFERRE_FAMILY = 16; 
  24. const NAME_PREFERRE_SUBFAMILY = 17; 
  25. const NAME_COMPAT_FULL_NAME = 18; 
  26. const NAME_SAMPLE_TEXT = 19; 
  27.  
  28. static $nameIdCodes = array( 
  29. 0 => "Copyright",  
  30. 1 => "FontName",  
  31. 2 => "FontSubfamily",  
  32. 3 => "UniqueID",  
  33. 4 => "FullName",  
  34. 5 => "Version",  
  35. 6 => "PostScriptName",  
  36. 7 => "Trademark",  
  37. 8 => "Manufacturer",  
  38. 9 => "Designer",  
  39. 10 => "Description",  
  40. 11 => "FontVendorURL",  
  41. 12 => "FontDesignerURL",  
  42. 13 => "LicenseDescription",  
  43. 14 => "LicenseURL",  
  44. // 15 
  45. 16 => "PreferredFamily",  
  46. 17 => "PreferredSubfamily",  
  47. 18 => "CompatibleFullName",  
  48. 19 => "SampleText",  
  49. ); 
  50.  
  51. static $platforms = array( 
  52. 0 => "Unicode",  
  53. 1 => "Macintosh",  
  54. // 2 => Reserved 
  55. 3 => "Microsoft",  
  56. ); 
  57.  
  58. static $plaformSpecific = array( 
  59. // Unicode 
  60. 0 => array( 
  61. 0 => "Default semantics",  
  62. 1 => "Version 1.1 semantics",  
  63. 2 => "ISO 10646 1993 semantics (deprecated)",  
  64. 3 => "Unicode 2.0 or later semantics",  
  65. ),  
  66.  
  67. // Macintosh 
  68. 1 => array( 
  69. 0 => "Roman",  
  70. 1 => "Japanese",  
  71. 2 => "Traditional Chinese",  
  72. 3 => "Korean",  
  73. 4 => "Arabic",  
  74. 5 => "Hebrew",  
  75. 6 => "Greek",  
  76. 7 => "Russian",  
  77. 8 => "RSymbol",  
  78. 9 => "Devanagari",  
  79. 10 => "Gurmukhi",  
  80. 11 => "Gujarati",  
  81. 12 => "Oriya",  
  82. 13 => "Bengali",  
  83. 14 => "Tamil",  
  84. 15 => "Telugu",  
  85. 16 => "Kannada",  
  86. 17 => "Malayalam",  
  87. 18 => "Sinhalese",  
  88. 19 => "Burmese",  
  89. 20 => "Khmer",  
  90. 21 => "Thai",  
  91. 22 => "Laotian",  
  92. 23 => "Georgian",  
  93. 24 => "Armenian",  
  94. 25 => "Simplified Chinese",  
  95. 26 => "Tibetan",  
  96. 27 => "Mongolian",  
  97. 28 => "Geez",  
  98. 29 => "Slavic",  
  99. 30 => "Vietnamese",  
  100. 31 => "Sindhi",  
  101. ),  
  102.  
  103. // Microsoft 
  104. 3 => array( 
  105. 0 => "Symbol",  
  106. 1 => "Unicode BMP (UCS-2)",  
  107. 2 => "ShiftJIS",  
  108. 3 => "PRC",  
  109. 4 => "Big5",  
  110. 5 => "Wansung",  
  111. 6 => "Johab",  
  112. // 7 => Reserved 
  113. // 8 => Reserved 
  114. // 9 => Reserved 
  115. 10 => "Unicode UCS-4",  
  116. ),  
  117. ); 
  118.  
  119. protected function _parse() { 
  120. $font = $this->getFont(); 
  121.  
  122. $tableOffset = $font->pos(); 
  123.  
  124. $data = $font->unpack(self::$header_format); 
  125.  
  126. $records = array(); 
  127. for($i = 0; $i < $data["count"]; $i++) { 
  128. $record = new Font_Table_name_Record(); 
  129. $record_data = $font->unpack(Font_Table_name_Record::$format); 
  130. $record->map($record_data); 
  131.  
  132. $records[] = $record; 
  133.  
  134. $names = array(); 
  135. foreach($records as $record) { 
  136. $font->seek($tableOffset + $data["stringOffset"] + $record->offset); 
  137. $s = $font->read($record->length); 
  138. $record->string = Font::UTF16ToUTF8($s); 
  139. $names[$record->nameID] = $record; 
  140.  
  141. $data["records"] = $names; 
  142.  
  143. $this->data = $data; 
  144.  
  145. protected function _encode() { 
  146. $font = $this->getFont(); 
  147.  
  148. /** @var Font_Table_name_Record[] $records */ 
  149. $records = $this->data["records"]; 
  150. $count_records = count($records); 
  151.  
  152. $this->data["count"] = $count_records; 
  153. $this->data["stringOffset"] = 6 + $count_records * 12; // 6 => uint16 * 3, 12 => sizeof self::$record_format 
  154.  
  155. $length = $font->pack(self::$header_format, $this->data); 
  156.  
  157. $offset = 0; 
  158. foreach($records as $record) { 
  159. $record->length = mb_strlen($record->getUTF16(), "8bit"); 
  160. $record->offset = $offset; 
  161. $offset += $record->length; 
  162. $length += $font->pack(Font_Table_name_Record::$format, (array)$record); 
  163.  
  164. foreach($records as $record) { 
  165. $str = $record->getUTF16(); 
  166. $length += $font->write($str, mb_strlen($str, "8bit")); 
  167.  
  168. return $length;