sfnt.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. ******************************************************************************
  3. *
  4. * © 2016 and later: Unicode, Inc. and others.
  5. * License & terms of use: http://www.unicode.org/copyright.html#License
  6. *
  7. ******************************************************************************
  8. ****************************************************************************** *
  9. *
  10. * Copyright (C) 1999-2001, International Business Machines
  11. * Corporation and others. All Rights Reserved.
  12. *
  13. ****************************************************************************** *
  14. * file name: sfnt.h
  15. *
  16. * created on: ??/??/2001
  17. * created by: Eric R. Mader
  18. */
  19. #ifndef __SFNT_H
  20. #define __SFNT_H
  21. #include "LETypes.h"
  22. #ifndef ANY_NUMBER
  23. #define ANY_NUMBER 1
  24. #endif
  25. struct DirectoryEntry
  26. {
  27. le_uint32 tag;
  28. le_uint32 checksum;
  29. le_uint32 offset;
  30. le_uint32 length;
  31. };
  32. struct SFNTDirectory
  33. {
  34. le_uint32 scalerType;
  35. le_uint16 numTables;
  36. le_uint16 searchRange;
  37. le_uint16 entrySelector;
  38. le_uint16 rangeShift;
  39. DirectoryEntry tableDirectory[ANY_NUMBER];
  40. };
  41. struct CMAPEncodingSubtableHeader
  42. {
  43. le_uint16 platformID;
  44. le_uint16 platformSpecificID;
  45. le_uint32 encodingOffset;
  46. };
  47. struct CMAPTable
  48. {
  49. le_uint16 version;
  50. le_uint16 numberSubtables;
  51. CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
  52. };
  53. struct CMAPEncodingSubtable
  54. {
  55. le_uint16 format;
  56. le_uint16 length;
  57. le_uint16 language;
  58. };
  59. struct CMAPFormat0Encoding : CMAPEncodingSubtable
  60. {
  61. le_uint8 glyphIndexArray[256];
  62. };
  63. struct CMAPFormat2Subheader
  64. {
  65. le_uint16 firstCode;
  66. le_uint16 entryCount;
  67. le_int16 idDelta;
  68. le_uint16 idRangeOffset;
  69. };
  70. struct CMAPFormat2Encoding : CMAPEncodingSubtable
  71. {
  72. le_uint16 subHeadKeys[256];
  73. CMAPFormat2Subheader subheaders[ANY_NUMBER];
  74. };
  75. struct CMAPFormat4Encoding : CMAPEncodingSubtable
  76. {
  77. le_uint16 segCountX2;
  78. le_uint16 searchRange;
  79. le_uint16 entrySelector;
  80. le_uint16 rangeShift;
  81. le_uint16 endCodes[ANY_NUMBER];
  82. // le_uint16 reservedPad;
  83. // le_uint16 startCodes[ANY_NUMBER];
  84. // le_uint16 idDelta[ANY_NUMBER];
  85. // le_uint16 idRangeOffset[ANY_NUMBER];
  86. // le_uint16 glyphIndexArray[ANY_NUMBER];
  87. };
  88. struct CMAPFormat6Encoding : CMAPEncodingSubtable
  89. {
  90. le_uint16 firstCode;
  91. le_uint16 entryCount;
  92. le_uint16 glyphIndexArray[ANY_NUMBER];
  93. };
  94. struct CMAPEncodingSubtable32
  95. {
  96. le_uint32 format;
  97. le_uint32 length;
  98. le_uint32 language;
  99. };
  100. struct CMAPGroup
  101. {
  102. le_uint32 startCharCode;
  103. le_uint32 endCharCode;
  104. le_uint32 startGlyphCode;
  105. };
  106. struct CMAPFormat8Encoding : CMAPEncodingSubtable32
  107. {
  108. le_uint32 is32[65536/32];
  109. le_uint32 nGroups;
  110. CMAPGroup groups[ANY_NUMBER];
  111. };
  112. struct CMAPFormat10Encoding : CMAPEncodingSubtable32
  113. {
  114. le_uint32 startCharCode;
  115. le_uint32 numCharCodes;
  116. le_uint16 glyphs[ANY_NUMBER];
  117. };
  118. struct CMAPFormat12Encoding : CMAPEncodingSubtable32
  119. {
  120. le_uint32 nGroups;
  121. CMAPGroup groups[ANY_NUMBER];
  122. };
  123. typedef le_int32 fixed;
  124. struct BigDate
  125. {
  126. le_uint32 bc;
  127. le_uint32 ad;
  128. };
  129. struct HEADTable
  130. {
  131. fixed version;
  132. fixed fontRevision;
  133. le_uint32 checksumAdjustment;
  134. le_uint32 magicNumber;
  135. le_uint16 flags;
  136. le_uint16 unitsPerEm;
  137. BigDate created;
  138. BigDate modified;
  139. le_int16 xMin;
  140. le_int16 yMin;
  141. le_int16 xMax;
  142. le_int16 yMax;
  143. le_int16 lowestRecPPEM;
  144. le_int16 fontDirectionHint;
  145. le_int16 indexToLocFormat;
  146. le_int16 glyphDataFormat;
  147. };
  148. struct MAXPTable
  149. {
  150. fixed version;
  151. le_uint16 numGlyphs;
  152. le_uint16 maxPoints;
  153. le_uint16 maxContours;
  154. le_uint16 maxComponentPoints;
  155. le_uint16 maxComponentContours;
  156. le_uint16 maxZones;
  157. le_uint16 maxTwilightPoints;
  158. le_uint16 maxStorage;
  159. le_uint16 maxFunctionDefs;
  160. le_uint16 maxInstructionDefs;
  161. le_uint16 maxStackElements;
  162. le_uint16 maxSizeOfInstructions;
  163. le_uint16 maxComponentElements;
  164. le_uint16 maxComponentDepth;
  165. };
  166. struct HHEATable
  167. {
  168. fixed version;
  169. le_int16 ascent;
  170. le_int16 descent;
  171. le_int16 lineGap;
  172. le_uint16 advanceWidthMax;
  173. le_int16 minLeftSideBearing;
  174. le_int16 minRightSideBearing;
  175. le_int16 xMaxExtent;
  176. le_int16 caretSlopeRise;
  177. le_int16 caretSlopeRun;
  178. le_int16 caretOffset;
  179. le_int16 reserved1;
  180. le_int16 reserved2;
  181. le_int16 reserved3;
  182. le_int16 reserved4;
  183. le_int16 metricDataFormat;
  184. le_uint16 numOfLongHorMetrics;
  185. };
  186. struct LongHorMetric
  187. {
  188. le_uint16 advanceWidth;
  189. le_int16 leftSideBearing;
  190. };
  191. struct HMTXTable
  192. {
  193. LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
  194. // le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
  195. };
  196. #endif