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.

496 lines
15 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation
  3. Module Name:
  4. prntfont.h
  5. Abstract:
  6. Declarations for Windows NT printer driver font metrics and glyphset data
  7. *.UFF, *.UFM and *.GTT file data structure definition
  8. --*/
  9. #ifndef _PRNTFONT_H_
  10. #define _PRNTFONT_H_
  11. //
  12. //
  13. // F O N T M E T R I C S ( U F M )
  14. //
  15. //
  16. //
  17. // NOTE: To include this header file, it is necessary to include
  18. // winddi.h, that has a definition of IFIMETRICS, FD_KERNINGPAIR
  19. //
  20. //
  21. //
  22. // UNIFM
  23. //
  24. // Universal printer driver (UNIDRV) font file header.
  25. //
  26. #define UNIFM_VERSION_1_0 0x00010000
  27. typedef struct _UNIFM_HDR
  28. {
  29. DWORD dwSize; // a total size of this font file
  30. DWORD dwVersion; // a version number of this font file
  31. ULONG ulDefaultCodepage; // this font's default codepage
  32. LONG lGlyphSetDataRCID; // a resource ID of GLYPHDATA
  33. DWORD loUnidrvInfo; // offset to UNIDRVINFO
  34. DWORD loIFIMetrics; // offset to IFIMETRICS
  35. DWORD loExtTextMetric; // offset to EXTTEXTMETRIC
  36. DWORD loWidthTable; // offset to WIDTHTABLE
  37. DWORD loKernPair; // offset to KERNPAIR
  38. DWORD dwReserved[2];
  39. } UNIFM_HDR, *PUNIFM_HDR;
  40. #define GET_UNIDRVINFO(pUFM) \
  41. ((PUNIDRVINFO)((PBYTE)(pUFM) + (pUFM)->loUnidrvInfo))
  42. #define GET_IFIMETRICS(pUFM) \
  43. ((IFIMETRICS*)((PBYTE)(pUFM) + (pUFM)->loIFIMetrics))
  44. #define GET_EXTTEXTMETRIC(pUFM) \
  45. ((EXTTEXTMETRIC*)((PBYTE)(pUFM) + (pUFM)->loExtTextMetric))
  46. #define GET_WIDTHTABLE(pUFM) \
  47. ((PWIDTHTABLE)((PBYTE)(pUFM) + (pUFM)->loWidthTable))
  48. #define GET_KERNDATA(pUFM) \
  49. ((PKERNDATA)((PBYTE)(pUFM) + (pUFM)->loKernPair))
  50. //
  51. // UNIDRVINFO
  52. //
  53. // UNIDRVINFO is used to define printer specific information.
  54. //
  55. typedef struct _INVOC {
  56. DWORD dwCount; // the number of bytes in the invocation string
  57. DWORD loOffset; // byte-offset to the beginning of the array
  58. } INVOC, *PINVOC;
  59. typedef struct _UNIDRVINFO
  60. {
  61. DWORD dwSize;
  62. DWORD flGenFlags;
  63. WORD wType;
  64. WORD fCaps;
  65. WORD wXRes;
  66. WORD wYRes;
  67. short sYAdjust;
  68. short sYMoved;
  69. WORD wPrivateData;
  70. short sShift;
  71. INVOC SelectFont;
  72. INVOC UnSelectFont;
  73. WORD wReserved[4];
  74. } UNIDRVINFO, *PUNIDRVINFO;
  75. #define GET_SELECT_CMD(pUni) \
  76. ((PCHAR)(pUni) + (pUni)->SelectFont.loOffset)
  77. #define GET_UNSELECT_CMD(pUni) \
  78. ((PCHAR)(pUni) + (pUni)->UnSelectFont.loOffset)
  79. //
  80. // flGenFlags
  81. //
  82. #define UFM_SOFT 0x00000001 // Softfont, thus needs downloading
  83. #define UFM_CART 0x00000002 // This is a cartridge font
  84. #define UFM_SCALABLE 0x00000004 // Font is scalable
  85. //
  86. // wType
  87. //
  88. #define DF_TYPE_HPINTELLIFONT 0 // HP's Intellifont
  89. #define DF_TYPE_TRUETYPE 1 // HP's PCLETTO fonts on LJ4
  90. #define DF_TYPE_PST1 2 // Lexmark PPDS scalable fonts
  91. #define DF_TYPE_CAPSL 3 // Canon CAPSL scalable fonts
  92. #define DF_TYPE_OEM1 4 // OEM scalable font type 1
  93. #define DF_TYPE_OEM2 5 // OEM scalable font type 2
  94. //
  95. // fCaps
  96. //
  97. #define DF_NOITALIC 0x0001 // Cannot italicize via FONTSIMULATION
  98. #define DF_NOUNDER 0x0002 // Cannot underline via FONTSIMULATION
  99. #define DF_XM_CR 0x0004 // send CR after using this font
  100. #define DF_NO_BOLD 0x0008 // Cannot bold via FONTSIMULATION
  101. #define DF_NO_DOUBLE_UNDERLINE 0x0010 // Cannot double underline via
  102. // FONTSIMU ATION
  103. #define DF_NO_STRIKETHRU 0x0020 // Cannot strikethru via FONTSIMULATION
  104. #define DF_BKSP_OK 0x0040 // Can use backspace char, see spec
  105. // for details
  106. //
  107. // EXTTEXTMETRIC
  108. //
  109. // The EXTTEXTMETRIC structure provides extended-metric information for a font.
  110. // All the measurements are given in the specified units,
  111. // regardless of the current mapping mode of the display context.
  112. //
  113. #ifndef _EXTTEXTMETRIC_
  114. #define _EXTTEXTMETRIC_
  115. typedef struct _EXTTEXTMETRIC
  116. {
  117. short emSize;
  118. short emPointSize;
  119. short emOrientation;
  120. short emMasterHeight;
  121. short emMinScale;
  122. short emMaxScale;
  123. short emMasterUnits;
  124. short emCapHeight;
  125. short emXHeight;
  126. short emLowerCaseAscent;
  127. short emLowerCaseDescent;
  128. short emSlant;
  129. short emSuperScript;
  130. short emSubScript;
  131. short emSuperScriptSize;
  132. short emSubScriptSize;
  133. short emUnderlineOffset;
  134. short emUnderlineWidth;
  135. short emDoubleUpperUnderlineOffset;
  136. short emDoubleLowerUnderlineOffset;
  137. short emDoubleUpperUnderlineWidth;
  138. short emDoubleLowerUnderlineWidth;
  139. short emStrikeOutOffset;
  140. short emStrikeOutWidth;
  141. WORD emKernPairs;
  142. WORD emKernTracks;
  143. } EXTTEXTMETRIC, *PEXTTEXTMETRIC;
  144. #endif // _EXTTEXTMETRIC_
  145. //
  146. // WIDTHTABLE
  147. //
  148. // This data structure represents the character width table.
  149. // This width table is a continuous GLYPHHANDLE base,
  150. // not Unicode nor codepage/character code base.
  151. // GLYPHANDLE information is in the GLYPHDATA.
  152. //
  153. typedef struct _WIDTHRUN
  154. {
  155. WORD wStartGlyph; // index of the first glyph handle
  156. WORD wGlyphCount; // number of glyphs covered
  157. DWORD loCharWidthOffset; // glyph width table
  158. } WIDTHRUN, *PWIDTHRUN;
  159. typedef struct _WIDTHTABLE
  160. {
  161. DWORD dwSize; // the size of this structure including every run
  162. DWORD dwRunNum; // the number of widthrun
  163. WIDTHRUN WidthRun[1]; // width run array
  164. } WIDTHTABLE, *PWIDTHTABLE;
  165. //
  166. // The array has wGlyphCount elements and each element is the char width
  167. // for a single glyph. The first width corresponds to glyph index wStartGlyph
  168. // and so on. The byte offset is relative to the beginning of WIDTHTABLE
  169. // structure and must be WORD-aligned.
  170. // In case of Western device font, proportional font has all varibal pitch
  171. // characters. This means that dwRunNum is set to 1 and loCharWidthOffset
  172. // would be an offset from the top of WIDTHTABLE to a width vector of all
  173. // characters.
  174. // In case of Far Eastern device font, basically IFIMETRICS.fwdAveCharWidth and
  175. // IFIMETRICS.fwdMaxCharWidth are used for single byte and double byte character
  176. // width. If a font is proportional, a UFM has a WIDTHTABLE which represents
  177. // only the proportional pitch characters. Other characters use fdwAveCharWidth
  178. // and fwdMaxCharInc for single and double byte characters.
  179. //
  180. //
  181. // KERNDATA
  182. // This data structure represents kerning pair information.
  183. // This kerning pair table is a Unicode base.
  184. //
  185. typedef struct _KERNDATA
  186. {
  187. DWORD dwSize; // the size of this structure including array
  188. DWORD dwKernPairNum; // the number of kerning pair
  189. FD_KERNINGPAIR KernPair[1]; // FD_KERNINGPAIR array
  190. } KERNDATA, *PKERNDATA;
  191. //
  192. //
  193. // G L Y P H S E T D A T A ( G T T )
  194. //
  195. //
  196. //
  197. // UNI_GLYPHSETDATA
  198. //
  199. // GLYPHSETDATA data structure represents a character encoding information
  200. // of printer device font.
  201. //
  202. typedef struct _UNI_GLYPHSETDATA {
  203. DWORD dwSize;
  204. DWORD dwVersion;
  205. DWORD dwFlags;
  206. LONG lPredefinedID;
  207. DWORD dwGlyphCount;
  208. DWORD dwRunCount;
  209. DWORD loRunOffset;
  210. DWORD dwCodePageCount;
  211. DWORD loCodePageOffset;
  212. DWORD loMapTableOffset;
  213. DWORD dwReserved[2];
  214. } UNI_GLYPHSETDATA, *PUNI_GLYPHSETDATA;
  215. #define UNI_GLYPHSETDATA_VERSION_1_0 0x00010000
  216. #define GET_GLYPHRUN(pGTT) \
  217. ((PGLYPHRUN) ((PBYTE)(pGTT) + ((PUNI_GLYPHSETDATA)pGTT)->loRunOffset))
  218. #define GET_CODEPAGEINFO(pGTT) \
  219. ((PUNI_CODEPAGEINFO) ((PBYTE)(pGTT) + ((PUNI_GLYPHSETDATA)pGTT)->loCodePageOffset))
  220. #define GET_MAPTABLE(pGTT) \
  221. ((PMAPTABLE) ((PBYTE)(pGTT) + ((PUNI_GLYPHSETDATA)pGTT)->loMapTableOffset))
  222. //
  223. // UNI_CODEPAGEINFO
  224. //
  225. // This UNI_CODEPAGEINFO dats structure has a list of Codepage values
  226. // which are supported by this UNI_GLYPHSETDATA.
  227. //
  228. typedef struct _UNI_CODEPAGEINFO {
  229. DWORD dwCodePage;
  230. INVOC SelectSymbolSet;
  231. INVOC UnSelectSymbolSet;
  232. } UNI_CODEPAGEINFO, *PUNI_CODEPAGEINFO;
  233. //
  234. // GLYPHRUN
  235. //
  236. // GLYPHRUN dats structure represents the conversion table from Unicode to
  237. // UNI_GLYPHSETDATA specific glyph handle. Glyph handle is continuous number
  238. // starting from zero.
  239. //
  240. typedef struct _GLYPHRUN {
  241. WCHAR wcLow;
  242. WORD wGlyphCount;
  243. } GLYPHRUN, *PGLYPHRUN;
  244. //
  245. // MAPTABLE and TRANSDATA
  246. //
  247. // This MAPTABLE data structure represents a conversion table fron glyph handle
  248. // to codepage/character code.
  249. //
  250. typedef struct _TRANSDATA {
  251. BYTE ubCodePageID; // Codepage index to CODEPAGENFO data structure array
  252. BYTE ubType; // a type of TRANSDATA
  253. union
  254. {
  255. SHORT sCode;
  256. BYTE ubCode;
  257. BYTE ubPairs[2];
  258. } uCode;
  259. } TRANSDATA, *PTRANSDATA;
  260. typedef struct _MAPTABLE {
  261. DWORD dwSize; // the size of MAPTABLE including TRANSDATA array
  262. DWORD dwGlyphNum; // the number of glyphs supported in MAPTABLE
  263. TRANSDATA Trans[1]; // an array of TRANSDATA
  264. } MAPTABLE, *PMAPTABLE;
  265. //
  266. // ubType flags
  267. //
  268. // One of following three can be specified for the type of uCode.
  269. //
  270. #define MTYPE_FORMAT_MASK 0x07
  271. #define MTYPE_COMPOSE 0x01 // wCode is an array of 16-bit offsets from the
  272. // beginning of the MAPTABLE pointing to the
  273. // strings to use for translation.
  274. // bData representes thelength of the translated
  275. // string.
  276. #define MTYPE_DIRECT 0x02 // wCode is a byte data of one-to-one translation
  277. #define MTYPE_PAIRED 0x04 // wCode contains a word data to emit.
  278. //
  279. // One of following tow can be specified for Far East multibyte character.
  280. //
  281. #define MTYPE_DOUBLEBYTECHAR_MASK 0x18
  282. #define MTYPE_SINGLE 0x08 // wCode contains a single byte character code in
  283. // multi byte character string.
  284. #define MTYPE_DOUBLE 0x10 // wCode contains a double byte character code in
  285. // multi byte character string.
  286. //
  287. // One of following three can be specified for replace/add/disable system
  288. // predefined GTT.
  289. //
  290. #define MTYPE_PREDEFIN_MASK 0xe0
  291. #define MTYPE_REPLACE 0x20 // wCode contains a data to replace predefined one.
  292. #define MTYPE_ADD 0x40 // wCode contains a data to add to predefiend one.
  293. #define MTYPE_DISABLE 0x80 // wCode contains a data to remove from predefined.
  294. //
  295. // System predefined character conversion
  296. //
  297. // UNIDRV is going to support following system predefined character conversion.
  298. // By speciffying these number in UNIFM.dwGlyphSetDataRCID;
  299. //
  300. #define CC_NOPRECNV 0x0000FFFF // Not use predefined
  301. //
  302. // ANSI
  303. //
  304. #define CC_DEFAULT 0 // Default Character Conversion
  305. #define CC_CP437 -1 // Unicode to IBM Codepage 437
  306. #define CC_CP850 -2 // Unicode to IBM Codepage 850
  307. #define CC_CP863 -3 // Unicode to IBM Codepage 863
  308. //
  309. // Far East
  310. //
  311. #define CC_BIG5 -10 // Unicode to Chinese Big 5. Codepage 950.
  312. #define CC_ISC -11 // Unicode to Korean Industrial Standard. Codepage 949.
  313. #define CC_JIS -12 // Unicode to JIS X0208. Codepage 932.
  314. #define CC_JIS_ANK -13 // Unicode to JIS X0208 except ANK. Codepage 932.
  315. #define CC_NS86 -14 // Big-5 to National Standstand conversion. Codepage 950
  316. #define CC_TCA -15 // Big-5 to Taipei Computer Association. Codepage 950.
  317. #define CC_GB2312 -16 // Unicode to GB2312. Codepage 936
  318. #define CC_SJIS -17 // Unicode to Shift-JIS. Codepage 932.
  319. #define CC_WANSUNG -18 // Unicode to Extented Wansung. Codepage 949.
  320. //
  321. //
  322. // U N I V E R S A L F O N T F O R M A T ( U F F )
  323. //
  324. //
  325. //
  326. // Font file header
  327. //
  328. typedef struct _UFF_FILEHEADER {
  329. DWORD dwSignature; // File magic number
  330. DWORD dwVersion; // UFF file format version number
  331. DWORD dwSize; // Size of this structure
  332. DWORD nFonts; // Count of fonts in directory
  333. DWORD nGlyphSets; // Count of glyph set data
  334. DWORD nVarData; // Count of variable data
  335. DWORD offFontDir; // Offset of font directory
  336. DWORD dwFlags; // Miscellaneous flags
  337. DWORD dwReserved[4]; // Reserved, set to zero
  338. } UFF_FILEHEADER, *PUFF_FILEHEADER;
  339. //
  340. // Values used in the file header
  341. //
  342. #define UFF_FILE_MAGIC '1FFU'
  343. #define UFF_VERSION_NUMBER 0x00010001
  344. #define FONT_DIR_SORTED 0x00000001
  345. //
  346. // Font directory structure
  347. //
  348. typedef struct _UFF_FONTDIRECTORY {
  349. DWORD dwSignature; // Signature of font metrics record
  350. WORD wSize; // Size of this structure
  351. WORD wFontID; // Unique font ID
  352. SHORT sGlyphID; // Associated glyph ID. 0 is default.
  353. // -ve values are predefined IDs
  354. WORD wFlags; // Miscellaneous flags
  355. DWORD dwInstallerSig; // Signature of installer that installed this font
  356. DWORD offFontName; // Offset to name of font
  357. DWORD offCartridgeName; // Offset to name of font cartridge
  358. DWORD offFontData; // Offset to font data record
  359. DWORD offGlyphData; // Offset to glyph set data
  360. DWORD offVarData; // Offset to softfont data
  361. } UFF_FONTDIRECTORY, *PUFF_FONTDIRECTORY;
  362. #define FONT_REC_SIG 'CERF' // font metrics record signature
  363. #define WINNT_INSTALLER_SIG 'IFTN' // NT font installer
  364. //
  365. // Flags used in font directory
  366. //
  367. #define FONT_FL_UFM 0x0001
  368. #define FONT_FL_IFI 0x0002
  369. #define FONT_FL_SOFTFONT 0x0004
  370. #define FONT_FL_PERMANENT_SF 0x0008
  371. #define FONT_FL_DEVICEFONT 0x0010
  372. #define FONT_FL_GLYPHSET_GTT 0x0020
  373. #define FONT_FL_GLYPHSET_RLE 0x0040
  374. #define FONT_FL_RESERVED 0x8000
  375. //
  376. // Data header
  377. //
  378. typedef struct _DATA_HEADER {
  379. DWORD dwSignature; // Signature of data type
  380. WORD wSize; // Size of this structure
  381. WORD wDataID; // Identifier number for data
  382. DWORD dwDataSize; // Size of data excluding structure
  383. DWORD dwReserved; // Reserved, set to zero
  384. } DATA_HEADER, *PDATA_HEADER;
  385. //
  386. // Data signatures
  387. //
  388. #define DATA_UFM_SIG 'MFUD'
  389. #define DATA_IFI_SIG 'IFID'
  390. #define DATA_GTT_SIG 'TTGD'
  391. #define DATA_CTT_SIG 'TTCD'
  392. #define DATA_VAR_SIG 'RAVD'
  393. //
  394. // Structure passed to font installer dialog proc through LPARAM
  395. //
  396. typedef struct _OEMFONTINSTPARAM {
  397. DWORD cbSize;
  398. HANDLE hPrinter;
  399. HANDLE hModule;
  400. HANDLE hHeap;
  401. DWORD dwFlags;
  402. PWSTR pFontInstallerName;
  403. } OEMFONTINSTPARAM, *POEMFONTINSTPARAM;
  404. #define FG_CANCHANGE 0x00080 // Have access to change data
  405. #define WM_FI_FILENAME 900 // To get the font installer name.
  406. #endif //_PRNTFONT_H_