Leaked source code of windows server 2003
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.

313 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. xltt.h
  5. Abstract:
  6. TrueType font handlig object
  7. Environment:
  8. Windows Whistler
  9. Revision History:
  10. 03/23/00
  11. Created it.
  12. --*/
  13. #ifndef _XLTT_H_
  14. #define _XLTT_H_
  15. //
  16. // TrueType font
  17. //
  18. // Header
  19. //
  20. typedef struct _TTHEADER {
  21. DWORD dwSfntVersion;
  22. USHORT usNumTables;
  23. USHORT usSearchRange;
  24. USHORT usEntrySelector;
  25. USHORT usRangeShift;
  26. } TTHEADER, *PTTHEADER;
  27. typedef struct _TTCHEADER {
  28. DWORD dwTTCTag;
  29. DWORD dwVersion;
  30. ULONG ulDirCount;
  31. } TTCHEADER, *PTTCHEADER;
  32. //
  33. // Directory
  34. //
  35. typedef struct _TTDIR {
  36. ULONG ulTag;
  37. ULONG ulCheckSum;
  38. ULONG ulOffset;
  39. ULONG ulLength;
  40. } TTDIR, *PTTDIR;
  41. //
  42. // head table
  43. //
  44. typedef DWORD longDateTime[2];
  45. typedef struct _HEAD {
  46. DWORD Tableversionnumber;
  47. DWORD fontRevision;
  48. ULONG checkSumAdjustment;
  49. ULONG magicNumber;
  50. USHORT flags;
  51. USHORT unitsPerEm;
  52. longDateTime created;
  53. longDateTime modified;
  54. FWORD xMin;
  55. FWORD yMin;
  56. FWORD xMax;
  57. FWORD yMax;
  58. USHORT macStyle;
  59. USHORT lowestRecPPEM;
  60. SHORT fontDirectionHint;
  61. SHORT indexToLocFormat;
  62. SHORT glyphDataFormat;
  63. } HEAD, *PHEAD;
  64. //
  65. // maxp table
  66. //
  67. typedef struct _MAXP {
  68. DWORD Tableversionnumber;
  69. USHORT numGlyphs;
  70. USHORT maxPoints;
  71. USHORT maxContours;
  72. USHORT maxCompositePoints;
  73. USHORT maxCompositeContours;
  74. USHORT maxZones;
  75. USHORT maxTwilightPoints;
  76. USHORT maxStorage;
  77. USHORT maxFunctionDefs;
  78. USHORT maxInstructionDefs;
  79. USHORT maxStackElements;
  80. USHORT maxSizeOfInstructions;
  81. USHORT maxComponentElements;
  82. USHORT maxComponentDepth;
  83. } MAXP, *PMAXP;
  84. //
  85. // hhea table
  86. //
  87. typedef struct _HHEA {
  88. DWORD dwVersion;
  89. SHORT sAscender;
  90. SHORT sDescender;
  91. SHORT sLineGap;
  92. USHORT usAdvanceWidthMax;
  93. SHORT sMinLeftSideBearing;
  94. SHORT sMinRightSideBearing;
  95. SHORT sxMaxExtent;
  96. SHORT sCaretSlopeRise;
  97. SHORT sCaretSlopeRun;
  98. SHORT sCaretOffset;
  99. SHORT sReserved1;
  100. SHORT sReserved2;
  101. SHORT sReserved3;
  102. SHORT sReserved4;
  103. SHORT sMetricDataFormat;
  104. USHORT usNumberOfHMetrics;
  105. } HHEA, *PHHEA;
  106. //
  107. // vhea table
  108. //
  109. typedef struct _VHEA {
  110. DWORD dwVersion;
  111. SHORT sAscender;
  112. SHORT sDescender;
  113. SHORT sLineGap;
  114. USHORT usAdvanceHightMax;
  115. SHORT sMinTopSideBearing;
  116. SHORT sMinBottomSideBearing;
  117. SHORT syMaxExtent;
  118. SHORT sCaretSlopeRise;
  119. SHORT sCaretSlopeRun;
  120. SHORT sCaretOffset;
  121. SHORT sReserved1;
  122. SHORT sReserved2;
  123. SHORT sReserved3;
  124. SHORT sReserved4;
  125. SHORT sMetricDataFormat;
  126. USHORT usNumberOfVMetrics;
  127. } VHEA, *PVHEA;
  128. //
  129. // hmtx table
  130. //
  131. typedef struct _HMTX {
  132. USHORT usAdvanceWidth;
  133. SHORT sLeftSideBearing;
  134. } HMTX, *PHMTX;
  135. //
  136. // vmtx table
  137. //
  138. typedef struct _VMTX {
  139. USHORT usAdvanceWidth;
  140. SHORT sTopSideBearing;
  141. } VMTX, *PVMTX;
  142. //
  143. // glyf table
  144. //
  145. typedef struct _GLYF {
  146. SHORT numberOfContours;
  147. SHORT xMin;
  148. SHORT yMin;
  149. SHORT xMax;
  150. SHORT yMax;
  151. } GLYF, *PGLYF;
  152. //
  153. // Composite glyph description
  154. //
  155. // SHORT -1
  156. //
  157. #define COMPONENTCTRCOUNT -1
  158. typedef struct _CGLYF {
  159. SHORT flags;
  160. SHORT glyphIndex;
  161. SHORT argument1;
  162. SHORT argument2;
  163. } CGLYF, *PCGLYF;
  164. typedef struct _CGLYF_BYTE {
  165. SHORT flags;
  166. SHORT glyphIndex;
  167. BYTE argument1;
  168. BYTE argument2;
  169. } CGLYF_BYTE, *PCGLYF_BYTE;
  170. //
  171. // Format 1 Class 1 or 2 is used to download TrueType font.
  172. // Now hhea, hmtx, vhea, vmtx are not necessary.
  173. //
  174. typedef enum TagID {
  175. TagID_First = 0,
  176. TagID_cvt = 0,
  177. TagID_fpgm,
  178. TagID_gdir, // Empty table. This is a placeholder for the table that printer
  179. // will allocate to store downloaded charactres.
  180. TagID_head,
  181. TagID_maxp,
  182. TagID_perp,
  183. TagID_hhea,
  184. TagID_hmtx,
  185. TagID_vhea,
  186. TagID_vmtx,
  187. TagID_loca,
  188. TagID_glyf,
  189. TagID_os2,
  190. TagID_MAX,
  191. TagID_Header = TagID_vmtx + 1
  192. };
  193. typedef enum TTTag {
  194. TTTag_cvt = ' tvc', //0
  195. TTTag_fpgm = 'mgpf', //1
  196. TTTag_gdir = 'ridg', //2
  197. TTTag_head = 'daeh', //3
  198. TTTag_maxp = 'pxam', //4
  199. TTTag_perp = 'perp', //5
  200. TTTag_hhea = 'aehh', //6
  201. TTTag_hmtx = 'xtmh', //7
  202. TTTag_vhea = 'aehv', //8
  203. TTTag_vmtx = 'xtmv', //9
  204. TTTag_loca = 'acol', //10
  205. TTTag_glyf = 'fylg', //11
  206. TTTag_os2 = '2/SO', //12
  207. TTTag_ttcf = 'fctt', //13
  208. TTTag_INVALID = 0xFFFFFFFF
  209. };
  210. class XLTrueType
  211. #if DBG
  212. : public XLDebug
  213. #endif
  214. {
  215. SIGNATURE ('xltt')
  216. public:
  217. XLTrueType::
  218. XLTrueType(VOID);
  219. XLTrueType::
  220. ~XLTrueType(VOID);
  221. HRESULT OpenTTFile(FONTOBJ *pfo);
  222. HRESULT CloseTTFile(VOID);
  223. HRESULT SameFont(FONTOBJ* pfo);
  224. HRESULT IsTTC(VOID);
  225. HRESULT IsVertical(VOID);
  226. HRESULT IsDBCSFont(VOID);
  227. HRESULT GetHeader(PTTHEADER *pHeader);
  228. DWORD GetSizeOfTable(TTTag tag);
  229. HRESULT GetTableDir(TTTag tag, PVOID *pTable);
  230. HRESULT GetTable(TTTag tag, PVOID *pTable, PDWORD pdwSize);
  231. DWORD GetNumOfTag(VOID);
  232. HRESULT TagAndID(DWORD *pdwID, TTTag *ptag);
  233. HRESULT GetGlyphData(HGLYPH hGlyph, PBYTE *ppubGlyphData, PDWORD pdwGlyphDataSize);
  234. HRESULT GetHMTXData(HGLYPH hGlyph, PUSHORT pusAdvanceWidth, PSHORT psLeftSideBearing);
  235. HRESULT GetVMTXData(HGLYPH hGlyph, PUSHORT pusAdvanceWidth, PSHORT psTopSideBearing, PSHORT psLeftSideBearing);
  236. HRESULT GetTypoDescender(VOID);
  237. #if DBG
  238. VOID SetDbgLevel(DWORD dwLevel);
  239. #endif
  240. private:
  241. DWORD m_dwFlags;
  242. FONTOBJ *m_pfo;
  243. PVOID m_pTTFile;
  244. ULONG m_ulFileSize;
  245. PTTHEADER m_pTTHeader;
  246. USHORT m_usNumTables;
  247. PTTDIR m_pTTDirHead;
  248. DWORD m_dwNumTag;
  249. DWORD m_dwNumGlyph;
  250. PTTDIR m_pTTDir[TagID_MAX];
  251. DWORD m_dwNumOfHMetrics;
  252. DWORD m_dwNumOfVMetrics;
  253. HRESULT ParseTTDir(VOID);
  254. };
  255. //
  256. // XLTrueType.m_dwFlags
  257. //
  258. #define XLTT_TTC 0x00000001 // Font is TTC.
  259. #define XLTT_SHORT_OFFSET_TO_LOC 0x00000002 // Short offset to loca table
  260. #define XLTT_VERTICAL_FONT 0x00000004 // Font is a vertial font.
  261. #define XLTT_DIR_PARSED 0x80000000 // The table directory is
  262. // parsed.
  263. #endif // _XLTT_H_