Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
6.1 KiB

  1. /*
  2. * TrueType File Format Structure Definitions
  3. *
  4. * Copyright (c) 1997-1999 Microsoft Corporation.
  5. */
  6. /* Whole :
  7. +-----------------------+
  8. | Header |
  9. +-----------------------+
  10. | Tables |
  11. | |
  12. |
  13. | |
  14. +-----------------------+
  15. Header :
  16. ----------------------------------------------------------
  17. Fixed sfnt version 0x00010000
  18. ushort numTables Number of tables
  19. ushort searchRange (n^2 <= numtables)*16
  20. ushort entrySelector Log2(n^2<=numTables)
  21. ushort rangeShift NumTables*16-searchRange
  22. Table Directory Entries
  23. ----------------------------------------------------------
  24. Table Directory:
  25. ----------------------------------------------------------
  26. ulong tag 4-byte idetifier
  27. ulong checkSum CheckSum for this table
  28. ulong offset offset from beginning of
  29. TrueType font file
  30. ulong length Length of this table
  31. ----------------------------------------------------------
  32. Tables:
  33. ----------------------------------------------------------
  34. cmap character to glyph mapping
  35. glyf glyph data
  36. head font header
  37. hhea horizontal header
  38. hmtx hosizontal metrics
  39. loca index to location
  40. maxp maximum profile
  41. name naming table
  42. post PostScript information
  43. OS/2 OS/2 and Windows specific metrics
  44. --------------------------
  45. cvt Control Value Table
  46. fpgm font program
  47. hdmx hosizontal device metrics
  48. kern kerning
  49. LTSH Linear threshold table
  50. prep CVT Program
  51. WIN (reserved)
  52. VDMX Vertical Device Metrics table
  53. FOCA Reserved for IBM Font Object Content Architecture data
  54. PCLT PCL 5 table
  55. mort glyph metamorphosis table
  56. --------------------------
  57. vhea Vertical Header table
  58. vmtx Vertical metrics table
  59. ----------------------------------------------------------
  60. */
  61. #define TAGSIZ 4
  62. struct TTFHeader {
  63. char sfnt_version[4];
  64. short numTables;
  65. short searchRange;
  66. short entrySelector;
  67. short rangeShift;
  68. };
  69. struct TableEntry {
  70. char tagName[TAGSIZ];
  71. unsigned long checkSum;
  72. long ofs;
  73. long siz;
  74. };
  75. /***
  76. * cmap
  77. ***/
  78. struct CmapHead {
  79. short version;
  80. short nTbls;
  81. };
  82. struct CmapEncodingTbl {
  83. short PlatformID;
  84. short PlatformSpecEncID;
  85. long ofs;
  86. };
  87. struct CmapSubtable {
  88. short format;
  89. short length;
  90. short version;
  91. short segCnt2;
  92. short searchRange;
  93. short rangeShift;
  94. short endCnt[2];
  95. short reservedPad;
  96. short startCnt[2];
  97. short idDelta[2];
  98. short idRangeOfs[2];
  99. };
  100. /***
  101. * maxp
  102. ***/
  103. struct MaxpTbl {
  104. char version[4];
  105. short numGlyph;
  106. short maxPoints;
  107. short maxContours;
  108. short maxCompositePoints;
  109. short maxCompositeContours;
  110. short maxZones;
  111. short maxTwilightPoints;
  112. short maxStorage;
  113. short maxFunctionDefs;
  114. short maxInstructiondefs;
  115. short maxStackElements;
  116. short maxSizeOfInstructions;
  117. short maxComponentElements;
  118. short maxComponentDepth;
  119. };
  120. /***
  121. * name
  122. ***/
  123. struct NamingTable {
  124. short FormSel;
  125. short NRecs;
  126. short OfsToStr;
  127. /* Following NameRecords */
  128. };
  129. struct NameRecord {
  130. short PlatformID;
  131. short PlatformSpecEncID;
  132. short LanguageID;
  133. short NameID;
  134. short StringLength;
  135. short StringOfs;
  136. };
  137. /***
  138. * head
  139. ***/
  140. struct HeadTable {
  141. char version[4]; /* 0x00010000 */
  142. char revision[4];
  143. unsigned long chkSum;
  144. unsigned long magicNumber; /* 0x5F0F3CF5 */
  145. short flags;
  146. short unitsPerEm;
  147. char createdDate[8];
  148. char updatedDate[8];
  149. short xMin;
  150. short yMin;
  151. short xMax;
  152. short yMax;
  153. short macStyle;
  154. short lowestRecPPEM;
  155. short fontDirectionHint;
  156. short indexToLocFormat;
  157. short glyphDataFormat; /* 0*/
  158. };
  159. /***
  160. * hhea
  161. ***/
  162. struct HheaTable {
  163. char version[4];
  164. short Ascender;
  165. short Descender;
  166. short LineGap;
  167. short advanceWidthMax;
  168. short minLeftSideBearing;
  169. short minRightSideBearing;
  170. short xMaxExtent;
  171. short caretSlopeRise;
  172. short caretSlopeRun;
  173. short reserved[5];
  174. short metricDataFormat;
  175. short numberOfHMetrics;
  176. };
  177. /***
  178. * hmtx
  179. ***/
  180. struct HMetrics {
  181. short advanceWidth;
  182. short leftSideBearing;
  183. };
  184. /***
  185. * vhea
  186. ***/
  187. struct VheaTable {
  188. char version[4];
  189. short Ascender;
  190. short Descender;
  191. short LineGap;
  192. short advanceHeightMax;
  193. short minTopSideBearing;
  194. short minBottomSideBearing;
  195. short yMaxExtent;
  196. short caretSlopeRise;
  197. short caretSlopeRun;
  198. short caretOffset;
  199. short reserved[4];
  200. short metricDataFormat;
  201. short numOfLongVerMetrics;
  202. };
  203. /***
  204. * vmtx
  205. ***/
  206. struct VMetrics {
  207. short advanceHeight;
  208. short topSideBearing;
  209. };
  210. /***
  211. * post
  212. ***/
  213. struct postTable {
  214. char FormatType[4]; /* 00030000 */
  215. long italicAngle;
  216. short underlinePosition;
  217. short underlineThickness;
  218. unsigned long isFixedPitch;
  219. unsigned long minMemType42;
  220. unsigned long maxMemType42;
  221. unsigned long minMemType1;
  222. unsigned long maxMemType1;
  223. };
  224. /***
  225. * OS/2
  226. ***/
  227. /*
  228. typedef struct {
  229. char bFamily;
  230. char bSerifStyle;
  231. char bWeight;
  232. char bProportion;
  233. char bContrast;
  234. char bStrokeVariation;
  235. char bArmStyle;
  236. char bLetterform;
  237. char bMidline;
  238. char bXHeight;
  239. } PANOSE;
  240. */
  241. struct OS2Table {
  242. unsigned short version;
  243. short xAvgCharWidth;
  244. unsigned short usWeightClass;
  245. unsigned short usWidthClass;
  246. short fsType;
  247. short ySubscriptXSize;
  248. short ySubscriptYSize;
  249. short ySubscriptXOffset;
  250. short ySubscriptYOffset;
  251. short ySuperscriptXSize;
  252. short ySuperscriptYSize;
  253. short ySuperscriptXOffset;
  254. short ySuperscriptYOffset;
  255. short yStrikeoutSize;
  256. short yStrikeoutPosition;
  257. short sFamilyClass;
  258. PANOSE panose;
  259. unsigned long ulCharRange[4];
  260. char achVendID[4];
  261. unsigned short fsSelection;
  262. unsigned short usFirstCharIndex;
  263. unsigned short usLastCharIndex;
  264. short sTypoAscender;
  265. short sTypoDescender;
  266. short sTypoLineGap;
  267. unsigned short usWinAscent;
  268. unsigned short usWinDescent;
  269. };
  270. /***
  271. * glyf
  272. ***/
  273. struct glyfHead {
  274. short numberOfContour;
  275. short xMin, yMin;
  276. short xMax, yMax;
  277. };
  278. /** glyf data flag definition **/
  279. #define GLYF_ON_CURVE 0x01
  280. #define GLYF_X_SHORT 0x02 /* x is short */
  281. #define GLYF_Y_SHORT 0x04 /* y is short */
  282. #define GLYF_X_SHORT_N 0x02 /* x is short & negative */
  283. #define GLYF_Y_SHORT_N 0x04 /* y is short & negative */
  284. #define GLYF_X_SHORT_P 0x12 /* x is short & positive */
  285. #define GLYF_Y_SHORT_P 0x24 /* y is short & positive */
  286. #define GLYF_REPEAT 0x08
  287. #define GLYF_X_SAME 0x10
  288. #define GLYF_Y_SAME 0x20
  289. /***
  290. * Bounding Box ( Not for file structure )
  291. ***/
  292. struct BBX {
  293. int xMin, yMin;
  294. int xMax, yMax;
  295. };
  296. /* EOF */