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.

575 lines
17 KiB

  1. /*++
  2. Copyright (c) 1996 - 1999 Microsoft Corporation
  3. Module Name:
  4. sfttpcl.h
  5. Abstract:
  6. TT outline download header file.
  7. Environment:
  8. Windows NT Unidrv driver
  9. Revision History:
  10. 06/03/97 -ganeshp-
  11. Created
  12. dd-mm-yy -author-
  13. description
  14. --*/
  15. #ifndef _SFTTPCL_H
  16. #define _SFTTPCL_H
  17. /*
  18. * True Type data structures
  19. */
  20. typedef signed char SBYTE;
  21. /*
  22. * Table Directory for True Type Font files
  23. */
  24. #define TABLE_DIR_ENTRY_SIZE (16/sizeof(int))
  25. #define TABLE_DIR_ENTRY 4 * TABLE_DIR_ENTRY_SIZE
  26. #define SIZEOF_TABLEDIR 8 * TABLE_DIR_ENTRY
  27. typedef ULONG TT_TAG;
  28. #define TRUE_TYPE_HEADER 12
  29. #define NUM_DIR_ENTRIES 8
  30. typedef unsigned short int uFWord;
  31. typedef short int FWord;
  32. /* Some True Type Font default values */
  33. #define TT_QUALITY_LETTER 2
  34. #define DEF_WIDTHTYPE 0
  35. #define DEF_SERIFSTYLE 0
  36. #define DEF_FONTNUMBER 0
  37. #define DEF_STYLE 0x03e0
  38. #define DEF_TYPEFACE 254
  39. #define DEF_STROKEWEIGHT 0
  40. #define DEF_XHEIGHT 0
  41. #define DEF_CAPHEIGHT 0
  42. #define DEF_SYMBOLSET 0x7502
  43. #define MAX_SEGMENTS 0x200
  44. #define MAX_CHAR 0x100
  45. #define x_UNICODE 0x78
  46. #define H_UNICODE 0x48
  47. #define INVALID_GLYPH 0xffff
  48. #define MAX_FONTS 8
  49. #define MORE_COMPONENTS 0x20
  50. #define FIXED_SPACING 0
  51. #define PROPORTIONAL_SPACING 1
  52. #define LEN_FONTNAME 16
  53. #define LEN_PANOSE 10
  54. #define LEN_COMPLEMENTNUM 8
  55. #define UB_SYMBOLSET 56
  56. #define RESERVED_CHARID 0xffff
  57. #define PCL_MAXHEADER_SIZE 32767
  58. #define PANOSE_TAG 0x4150 // "PA" swapped
  59. #define CE_TAG 'EC'
  60. #define CC_TAG 'CC'
  61. #define GC_TAG 'CG'
  62. #define SEG_TAG 0x5447 // already swapped
  63. #define Null_TAG 0xffff
  64. #define CHAR_COMP_TAG 0x4343
  65. #define PLATFORM_MS 3
  66. #define SYMBOL_FONT 0
  67. #define UNICODE_FONT 1
  68. #define TT_BOUND_FONT 2
  69. #define TT_2BYTE_FONT 3
  70. #define TT_UNBOUND_FONT 11
  71. #define FAMILY_NAME 4
  72. // For Parsing Method 21 we need to start at 0x2100
  73. #define FIRST_TT_2B_CHAR_CODE 0x2100
  74. #define SHORT_OFFSET 0
  75. #define LONG_OFFSET 1
  76. /*
  77. * Constants used for compound glyphs
  78. */
  79. #define ARG_1_AND_2_ARE_WORDS 0x01
  80. #define WE_HAVE_A_SCALE 0x08
  81. #define MORE_COMPONENTS 0x20
  82. #define WE_HAVE_AN_X_AND_Y_SCALE 0x40
  83. #define WE_HAVE_A_TWO_BY_TWO 0x80
  84. /* TT Table directory header. This is the first str */
  85. typedef struct
  86. {
  87. FIXED version;
  88. USHORT numTables;
  89. USHORT searchRange;
  90. USHORT entrySelector;
  91. USHORT rangeShift;
  92. } TRUETYPEHEADER;
  93. /* TT Table directory structure. */
  94. typedef struct
  95. {
  96. ULONG uTag;
  97. ULONG uCheckSum;
  98. ULONG uOffset;
  99. ULONG uLength;
  100. } TABLEDIR;
  101. typedef TABLEDIR ATABLEDIR[NUM_DIR_ENTRIES];
  102. typedef TABLEDIR *PTABLEDIR;
  103. /* List of tables needed for PCL TT download. They are listed in order. */
  104. #define TABLEOS2 "OS/2" /* Not sent to PCL header */
  105. #define TABLEPCLT "PCLT" /* Not sent to PCL header */
  106. #define TABLECMAP "cmap" /* Not sent to PCL header */
  107. #define TABLECVT "cvt "
  108. #define TABLEFPGM "fpgm"
  109. #define TABLEGDIR "gdir" /* This is PCL specific table. Not a TT table */
  110. #define TABLEGLYF "glyf" /* This table is not sent in PCL font header */
  111. #define TABLEHEAD "head"
  112. #define TABLEHHEA "hhea"
  113. #define TABLEHMTX "hmtx"
  114. #define TABLELOCA "loca" /* Not sent to PCL header */
  115. #define TABLEMAXP "maxp"
  116. #define TABLENAME "name" /* Not sent to PCL header */
  117. #define TABLEPOST "post" /* Not sent to PCL header */
  118. #define TABLEPREP "prep"
  119. typedef struct
  120. {
  121. ULONG u1;
  122. ULONG u2;
  123. } DATETIME;
  124. typedef struct
  125. {
  126. FIXED version;
  127. FIXED fontRevision;
  128. ULONG checkSumAdjustment;
  129. ULONG magicNumber;
  130. USHORT flags;
  131. USHORT unitsPerEm;
  132. DATETIME dateCreated;
  133. DATETIME dateModified;
  134. SHORT xMin;
  135. SHORT yMin;
  136. SHORT xMax;
  137. SHORT yMax;
  138. USHORT macStyle;
  139. USHORT lowestRecPPEM;
  140. SHORT fontDirectionHint;
  141. SHORT indexToLocFormat;
  142. } HEAD_TABLE;
  143. typedef struct
  144. {
  145. BYTE stuff[34];
  146. USHORT numberOfHMetrics;
  147. } HHEA_TABLE;
  148. typedef struct {
  149. uFWord advanceWidth;
  150. FWord leftSideBearing;
  151. } HORIZONTALMETRICS;
  152. typedef struct {
  153. HORIZONTALMETRICS longHorMetric[1];
  154. } HMTXTABLE;
  155. typedef struct
  156. {
  157. uFWord advanceWidth;
  158. } HMTX_INFO;
  159. typedef struct
  160. {
  161. FIXED version;
  162. USHORT numGlyphs;
  163. } MAXP_TABLE;
  164. typedef struct
  165. {
  166. USHORT version;
  167. SHORT xAvgCharWidth;
  168. USHORT usWeightClass;
  169. USHORT usWidthClass;
  170. SHORT fsType;
  171. SHORT ySubscriptXSize;
  172. SHORT ySubscriptYSize;
  173. SHORT ySubscriptXOffset;
  174. SHORT ySubscriptYOffset;
  175. SHORT ySuperscriptXSize;
  176. SHORT ySuperscriptYSize;
  177. SHORT ySuperscriptXOffset;
  178. SHORT ySuperscriptYOffset;
  179. SHORT yStrikeoutSize;
  180. SHORT yStrikeoutPosition;
  181. SHORT sFamilyClass;
  182. PANOSE Panose;
  183. SHORT ss1;
  184. SHORT ss2;
  185. SHORT ss3;
  186. ULONG ulCharRange[3];
  187. SHORT ss4;
  188. USHORT fsSelection;
  189. USHORT usFirstCharIndex;
  190. USHORT usLastCharIndex;
  191. USHORT sTypoAscender;
  192. USHORT sTypoDescender;
  193. USHORT sTypoLineGap;
  194. USHORT usWinAscent;
  195. USHORT usWinDescent;
  196. } OS2_TABLE;
  197. typedef struct
  198. {
  199. FIXED FormatType;
  200. FIXED italicAngle;
  201. SHORT underlinePosition;
  202. SHORT underlineThickness;
  203. ULONG isFixedPitch; /* set to 0 if proportional, else !0 */
  204. } POST_TABLE;
  205. typedef struct
  206. {
  207. ULONG Version;
  208. ULONG FontNumber;
  209. USHORT Pitch;
  210. USHORT xHeight;
  211. USHORT Style;
  212. USHORT TypeFamily;
  213. USHORT CapHeight;
  214. USHORT SymbolSet;
  215. char Typeface[LEN_FONTNAME];
  216. char CharacterComplement[8];
  217. char FileName[6];
  218. char StrokeWeight;
  219. char WidthType;
  220. BYTE SerifStyle;
  221. } PCLT_TABLE;
  222. typedef struct
  223. {
  224. USHORT PlatformID;
  225. USHORT EncodingID;
  226. ULONG offset;
  227. } ENCODING_TABLE;
  228. typedef struct
  229. {
  230. USHORT Version;
  231. USHORT nTables;
  232. ENCODING_TABLE encodingTable[3];
  233. } CMAP_TABLE;
  234. typedef struct
  235. {
  236. USHORT format;
  237. USHORT length;
  238. USHORT Version;
  239. USHORT SegCountx2;
  240. USHORT SearchRange;
  241. USHORT EntrySelector;
  242. USHORT RangeShift;
  243. } GLYPH_MAP_TABLE;
  244. typedef struct
  245. {
  246. SHORT numberOfContours;
  247. FWord xMin;
  248. FWord yMin;
  249. FWord xMax;
  250. FWORD yMax;
  251. // SHORT GlyphDesc[1];
  252. } GLYPH_DATA_HEADER;
  253. typedef struct
  254. {
  255. CMAP_TABLE cmapTable;
  256. ULONG offset;
  257. } GLYPH_DATA;
  258. typedef struct
  259. {
  260. USHORT PlatformID;
  261. USHORT EncodingID;
  262. USHORT LanguageID;
  263. USHORT NameID;
  264. USHORT StringLen;
  265. USHORT StringOffset;
  266. } NAME_RECORD;
  267. typedef struct
  268. {
  269. USHORT FormatSelector;
  270. USHORT NumOfNameRecords;
  271. USHORT Offset;
  272. NAME_RECORD *pNameRecord;
  273. } NAME_TABLE;
  274. typedef struct
  275. {
  276. ULONG ulOffset;
  277. ULONG ulLength;
  278. } FONT_DATA;
  279. /* Segment data */
  280. #define CE_SEG_SIGNATURE 'EC'
  281. typedef struct
  282. {
  283. WORD wSig;
  284. WORD wSize;
  285. WORD wSizeAlign;
  286. WORD wStyle; // 1 = italics, 0,2,3=reserved.
  287. WORD wStyleAlign; // 1 = italics, 0,2,3=reserved.
  288. WORD wStrokeWeight;
  289. WORD wSizing;
  290. } CE_SEGMENT;
  291. //
  292. // From PCL TechRef.pdf
  293. //
  294. // Character Complement Numbers
  295. //
  296. // The "Intellifont Unbound Scalable Font Header" (header) includes a
  297. // 64 bit field (bytes 78-85) which contains the Character Complement
  298. // number. For TrueType fonts, in the "15 Font Header for
  299. // Scalable Fonts" (unbound), the Character Complement number is
  300. // included in the accompanying "Font Data" section of the
  301. // header.
  302. // The Character Complement number identifies the symbol collections
  303. // in the font. Each bit in this field corresponds to a symbol collection
  304. // (not all bits are currently defined; refer to Appendix D in the PCL 5
  305. // Comparison Guide).
  306. //
  307. // This 8-byte field works in conjunction with the Character Complement
  308. // field in the header of a type 10 or 11 (unbound) font to determine the
  309. // compatibility of a symbol set with an unbound font. These two fields
  310. // identify the unbound fonts in the printer which contain the symbol
  311. // collections required to build a symbol set. Refer to "Scalable
  312. // Fonts" in Chapter 9, for a description of symbol collections and
  313. // unbound fonts.
  314. // Each bit in the field represents a specific collection. Setting a bit to 1
  315. // indicates that collection is required; setting the bit to 0 indicates that
  316. // collection is not required. (Bit 63 refers to the most significant bit of
  317. // the first byte, and bit 0 refers to the least significant bit of the eight
  318. // byte field.) The bit representations for the collections are shown
  319. // below.
  320. //
  321. // MSL Symbol index
  322. //
  323. // Bit Field Designated Use
  324. // 58-63 Reserved for Latin fonts.
  325. // 55-57 Reserved for Cyrillic fonts.
  326. // 52-54 Reserved for Arabic fonts.
  327. // 50-51 Reserved for Greek fonts.
  328. // 48-49 Reserved for Hebrew fonts.
  329. // 3-47 Miscellaneous uses (South Asian, Armenian,
  330. // other alphabets, bar codes, OCR, Math, PC Semi-graphics, etc.).
  331. // 0-2 Symbol Index field. 111 - MSL Symbol Index
  332. //
  333. // Unicode Symbol Index
  334. //
  335. // Bit Field Designated Use
  336. // 32-63 Miscellaneous uses (South Asian, Armenian, other
  337. // alphabets, bar codes, OCR, Math, etc.).
  338. // 28-31 Reserved for Latin fonts.
  339. // 22-27 Reserved for platform/application variant fonts.
  340. // 3-21 Reserved for Cyrillic, Arabic, Greek and Hebrew fonts.
  341. // 0-2 Symbol Index field. 110 - Unicode Symbol Index
  342. //
  343. // MSL Symbol Index Character Complement Bits
  344. // Bit Value
  345. // 63 0 if font is compatible with standard Latin character
  346. // sets (e.g., Roman-8, ISO 8859-1 Latin 1);
  347. // 1 otherwise.
  348. // 62 0 if font is compatible with East European Latin
  349. // character sets (e.g., ISO 8859-2 Latin 2); 1 otherwise.
  350. // 61 0 if font contains Turkish character sets
  351. // (e.g., ISO 8859/9 Latin 5); 1 otherwise.
  352. // 34 0 if font has access to the math characters of the
  353. // Math-8, PS Math and Ventura Math character sets;
  354. // 1 otherwise.
  355. // 33 0 if font has access to the semi-graphic characters of
  356. // the PC-8, PC-850, etc. character sets; 1 otherwise.
  357. // 32 0 if font is compatible with ITC Zapf Dingbats series
  358. // 100, 200, etc.;
  359. // 1 otherwise.
  360. // 2, 1, 0
  361. // 111 if font is arranged in MSL Symbol Index order.
  362. //
  363. // Unicode Symbol Index Character Complement Bits
  364. // Bit Value
  365. // 31 0 if font is compatible with 7-bit ASCII;
  366. // 1 otherwise.
  367. // 30 0 if font is compatible with ISO 8859/1 Latin 1 (West
  368. // Europe) character sets;
  369. // 1 otherwise.
  370. // 29 0 if font is compatible with ISO 8859/2 Latin 2 (East
  371. // Europe) character sets;
  372. // 1 otherwise.
  373. // 28 0 if font is compatible with Latin 5 (Turkish) character
  374. // sets (e.g., ISO 8859/9 Latin 5, PC-Turkish);
  375. // 1 otherwise.
  376. // 27 0 if font is compatible with Desktop Publishing
  377. // character sets (e.g., Windows 3.1 Latin 1, DeskTop, MC Text);
  378. // 1 otherwise.
  379. // 26 0 if font is compatible with character sets requiring a
  380. // wider selection of accents (e.g., MC Text, ISO 8859/1 Latin 1);
  381. // 1 otherwise.
  382. // 25 0 if font is compatible with traditional PCL character
  383. // sets (e.g., Roman-8, Legal, ISO 4 United Kingdom);
  384. // 1 otherwise.
  385. // 24 0 if font is compatible with the Macintosh character set (MC Text);
  386. // 1 otherwise.
  387. // 23 0 if font is compatible with PostScript Standard Encoding (PS Text);
  388. // 1 otherwise.
  389. // 22 0 if font is compatible with Code Pages
  390. // (e.g., PC-8, PC 850, PC-Turk, etc.);
  391. // 1 otherwise.
  392. // 2,1,0
  393. // 110 if font is arranged in Unicode Symbol Index order.
  394. //
  395. #define CC_SEG_SIGNATURE 'CC'
  396. typedef struct
  397. {
  398. WORD wSig;
  399. WORD wSize;
  400. WORD wSizeAlign;
  401. //
  402. // 64 bit field
  403. //
  404. WORD wCCNumber1;
  405. WORD wCCNumber2;
  406. WORD wCCNumber3;
  407. WORD wCCNumber4;
  408. } CC_SEGMENT;
  409. #define GC_SEG_SIGNATURE 'CG'
  410. typedef struct
  411. {
  412. WORD wSig;
  413. WORD wSize;
  414. WORD wSizeAlign;
  415. WORD wFormat; // = 0
  416. WORD wDefaultGalleyChar; //FFFF
  417. WORD wNumberOfRegions; // 1 (Hebrew)
  418. struct {
  419. WORD wRegionUpperLeft; // 0
  420. WORD wRegionLowerRight; // FFFE
  421. WORD wRegional; // FFFE
  422. } RegionChar[1];
  423. } GC_SEGMENT;
  424. /* True Type character descriptor */
  425. typedef struct
  426. {
  427. BYTE bFormat;
  428. BYTE bContinuation;
  429. BYTE bDescSize;
  430. BYTE bClass;
  431. WORD wCharDataSize;
  432. WORD wGlyphID;
  433. } TTCH_HEADER;
  434. /* Unbound True Type Font Descriptor */
  435. typedef struct
  436. {
  437. USHORT usSize;
  438. BYTE bFormat;
  439. BYTE bFontType;
  440. BYTE bStyleMSB;
  441. BYTE bReserve1;
  442. USHORT usBaselinePosition;
  443. USHORT usCellWidth;
  444. USHORT usCellHeight;
  445. BYTE bOrientation;
  446. BYTE bSpacing;
  447. USHORT usSymbolSet;
  448. USHORT usPitch;
  449. USHORT usHeight;
  450. USHORT usXHeight;
  451. SBYTE sbWidthType;
  452. BYTE bStyleLSB;
  453. SBYTE sbStrokeWeight;
  454. BYTE bTypefaceLSB;
  455. BYTE bTypefaceMSB;
  456. BYTE bSerifStyle;
  457. BYTE bQuality;
  458. SBYTE sbPlacement;
  459. SBYTE sbUnderlinePos;
  460. SBYTE sbUnderlineThickness;
  461. USHORT Reserve2;
  462. USHORT Reserve3;
  463. USHORT Reserve4;
  464. USHORT usNumberContours;
  465. BYTE bPitchExtended;
  466. BYTE bHeightExtended;
  467. WORD wCapHeight;
  468. ULONG ulFontNum;
  469. char FontName[LEN_FONTNAME];
  470. WORD wScaleFactor;
  471. SHORT sMasterUnderlinePosition;
  472. USHORT usMasterUnderlineHeight;
  473. BYTE bFontScaling;
  474. BYTE bVariety;
  475. } UB_TT_HEADER;
  476. /* Bounded True Type Font Descriptor */
  477. typedef struct
  478. {
  479. USHORT usSize; /* Number of bytes in here */
  480. BYTE bFormat; /* Descriptor Format TT is 15 */
  481. BYTE bFontType; /* 7, 8, or PC-8 style font */
  482. BYTE bStyleMSB;
  483. BYTE wReserve1; /* Reserved */
  484. WORD wBaselinePosition; /* TT = 0 */
  485. USHORT wCellWide; /* head.xMax - xMin */
  486. USHORT wCellHeight; /* head.yMax - yMin */
  487. BYTE bOrientation; /* TT = 0 */
  488. BYTE bSpacing; /* post.isFixedPitch */
  489. WORD wSymSet; /* PCLT.symbolSet */
  490. WORD wPitch; /* hmtx.advanceWidth */
  491. WORD wHeight; /* TT = 0 */
  492. WORD wXHeight; /* PCLT.xHeight */
  493. SBYTE sbWidthType; /* PCLT.widthType */
  494. BYTE bStyleLSB;
  495. SBYTE sbStrokeWeight; /* OS2.usWeightClass */
  496. BYTE bTypefaceLSB; /* */
  497. BYTE bTypefaceMSB; /* */
  498. BYTE bSerifStyle; /* PCLT.serifStyle */
  499. BYTE bQuality;
  500. SBYTE sbPlacement; /* TT = 0 */
  501. SBYTE sbUnderlinePos; /* TT = 0 */
  502. SBYTE sbUnderlineThickness; /* TT = 0 */
  503. USHORT usTextHeight; /* Reserved */
  504. USHORT usTextWidth; /* Reserved */
  505. WORD wFirstCode; /* OS2.usFirstCharIndex */
  506. WORD wLastCode; /* OS2.usLastCharIndex */
  507. BYTE bPitchExtended; /* TT = 0 */
  508. BYTE bHeightExtended; /* TT = 0 */
  509. USHORT usCapHeight; /* PCLT.capHeight */
  510. ULONG ulFontNum; /* PCLT.FontNumber */
  511. char FontName[LEN_FONTNAME]; /* name.FontFamilyName */
  512. WORD wScaleFactor; /* head.unitsPerEm */
  513. SHORT sMasterUnderlinePosition; /* post.underlinePosition */
  514. USHORT usMasterUnderlineHeight; /* post.underlineThickness */
  515. BYTE bFontScaling; /* TT = 1 */
  516. BYTE bVariety; /* TT = 0 */
  517. } TT_HEADER;
  518. #endif // !_SFTTPCL_H