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.

233 lines
9.1 KiB

  1. //--------------------------------------------------------------------------
  2. //
  3. // Module Name: PFM.H
  4. //
  5. // Brief Description: This module contains the PSCRIPT driver's
  6. // font metrics defines.
  7. //
  8. // Author: Kent Settle (kentse)
  9. // Created: 22-Jan-1991
  10. //
  11. // Copyright (C) 1991 - 1999 Microsoft Corporation.
  12. //--------------------------------------------------------------------------
  13. #define MAX_KERNPAIRS 1024
  14. #define ANSI_CHARSET 0
  15. #define SYMBOL_CHARSET 2
  16. #define OEM_CHARSET 255
  17. #define NTM_VERSION 0x00010000
  18. #define FL_NTFM_SOFTFONT 1
  19. #define FL_NTFM_NO_TRANSLATE_CHARSET 2
  20. #define INIT_IFI 2048
  21. #define INIT_PFM 262144 + INIT_IFI // storage to allocate to build NTFM.
  22. #define MIN_UNICODE_VALUE 0
  23. #define MAX_UNICODE_VALUE 0xFFFE
  24. #define INVALID_UNICODE_VALUE 0xFFFF
  25. // The AFM tokens.
  26. #define TK_UNDEFINED 0
  27. #define TK_STARTKERNDATA 2
  28. #define TK_STARTKERNPAIRS 3
  29. #define TK_KPX 4
  30. #define TK_ENDKERNPAIRS 5
  31. #define TK_ENDKERNDATA 6
  32. #define TK_FONTNAME 7
  33. #define TK_WEIGHT 8
  34. #define TK_ITALICANGLE 9
  35. #define TK_ISFIXEDPITCH 10
  36. #define TK_UNDERLINEPOSITION 11
  37. #define TK_UNDERLINETHICKNESS 12
  38. #define TK_FONTBBOX 13
  39. #define TK_CAPHEIGHT 14
  40. #define TK_XHEIGHT 15
  41. #define TK_DESCENDER 16
  42. #define TK_ASCENDER 17
  43. #define TK_STARTCHARMETRICS 18
  44. #define TK_ENDCHARMETRICS 19
  45. #define TK_ENDFONTMETRICS 20
  46. #define TK_STARTFONTMETRICS 21
  47. #define TK_ENCODINGSCHEME 22
  48. #define TK_FULLNAME 23
  49. #define TK_FAMILYNAME 24
  50. #define TK_MSFAMILY 25
  51. // font defines.
  52. #define ARIAL 1
  53. #define ARIAL_BOLD 2
  54. #define ARIAL_BOLDOBLIQUE 3
  55. #define ARIAL_OBLIQUE 4
  56. #define ARIAL_NARROW 5
  57. #define ARIAL_NARROW_BOLD 6
  58. #define ARIAL_NARROW_BOLDOBLIQUE 7
  59. #define ARIAL_NARROW_OBLIQUE 8
  60. #define AVANTGARDE_BOOK 9
  61. #define AVANTGARDE_BOOKOBLIQUE 10
  62. #define AVANTGARDE_DEMI 11
  63. #define AVANTGARDE_DEMIOBLIQUE 12
  64. #define BOOKMAN_DEMI 13
  65. #define BOOKMAN_DEMIITALIC 14
  66. #define BOOKMAN_LIGHT 15
  67. #define BOOKMAN_LIGHTITALIC 16
  68. #define COURIER 17
  69. #define COURIER_BOLD 18
  70. #define COURIER_BOLDOBLIQUE 19
  71. #define COURIER_OBLIQUE 20
  72. #define GARAMOND_BOLD 21
  73. #define GARAMOND_BOLDITALIC 22
  74. #define GARAMOND_LIGHT 23
  75. #define GARAMOND_LIGHTITALIC 24
  76. #define HELVETICA 25
  77. #define HELVETICA_BLACK 26
  78. #define HELVETICA_BLACKOBLIQUE 27
  79. #define HELVETICA_BOLD 28
  80. #define HELVETICA_BOLDOBLIQUE 29
  81. #define HELVETICA_CONDENSED 30
  82. #define HELVETICA_CONDENSED_BOLD 31
  83. #define HELVETICA_CONDENSED_BOLDOBL 32
  84. #define HELVETICA_CONDENSED_OBLIQUE 33
  85. #define HELVETICA_LIGHT 34
  86. #define HELVETICA_LIGHTOBLIQUE 35
  87. #define HELVETICA_NARROW 36
  88. #define HELVETICA_NARROW_BOLD 37
  89. #define HELVETICA_NARROW_BOLDOBLIQUE 38
  90. #define HELVETICA_NARROW_OBLIQUE 39
  91. #define HELVETICA_OBLIQUE 40
  92. #define KORINNA_BOLD 41
  93. #define KORINNA_KURSIVBOLD 42
  94. #define KORINNA_KURSIVREGULAR 43
  95. #define KORINNA_REGULAR 44
  96. #define LUBALINGRAPH_BOOK 45
  97. #define LUBALINGRAPH_BOOKOBLIQUE 46
  98. #define LUBALINGRAPH_DEMI 47
  99. #define LUBALINGRAPH_DEMIOBLIQUE 48
  100. #define NEWCENTURYSCHLBK_BOLD 49
  101. #define NEWCENTURYSCHLBK_BOLDITALIC 50
  102. #define NEWCENTURYSCHLBK_ITALIC 51
  103. #define NEWCENTURYSCHLBK_ROMAN 52
  104. #define PALATINO_BOLD 53
  105. #define PALATINO_BOLDITALIC 54
  106. #define PALATINO_ITALIC 55
  107. #define PALATINO_ROMAN 56
  108. #define SOUVENIR_DEMI 57
  109. #define SOUVENIR_DEMIITALIC 58
  110. #define SOUVENIR_LIGHT 59
  111. #define SOUVENIR_LIGHTITALIC 60
  112. #define SYMBOL 61
  113. #define TIMES_BOLD 62
  114. #define TIMES_BOLDITALIC 63
  115. #define TIMES_ITALIC 64
  116. #define TIMES_ROMAN 65
  117. #define TIMES_NEW_ROMAN 66
  118. #define TIMES_NEW_ROMAN_BOLD 67
  119. #define TIMES_NEW_ROMAN_BOLDITALIC 68
  120. #define TIMES_NEW_ROMAN_ITALIC 69
  121. #define VARITIMES_BOLD 70
  122. #define VARITIMES_BOLDITALIC 71
  123. #define VARITIMES_ITALIC 72
  124. #define VARITIMES_ROMAN 73
  125. #define ZAPFCALLIGRAPHIC_BOLD 74
  126. #define ZAPFCALLIGRAPHIC_BOLDITALIC 75
  127. #define ZAPFCALLIGRAPHIC_ITALIC 76
  128. #define ZAPFCALLIGRAPHIC_ROMAN 77
  129. #define ZAPFCHANCERY_MEDIUMITALIC 78
  130. #define ZAPFDINGBATS 79
  131. #define FIRST_FONT 1
  132. #define DEFAULT_FONT COURIER
  133. #define NUM_INTERNAL_FONTS 79
  134. extern PutByte(SHORT);
  135. extern PutWord(SHORT);
  136. extern PutLong(long);
  137. typedef USHORT SOFFSET; // short offset.
  138. #define DWORDALIGN(a) ((a + (sizeof(DWORD) - 1)) & ~(sizeof(DWORD) - 1))
  139. #define WCHARALIGN(a) ((a + (sizeof(WCHAR) - 1)) & ~(sizeof(WCHAR) - 1))
  140. // entry for each soft font.
  141. // NT Font Metrics structure.
  142. typedef ULONG LOFFSET; // long offset.
  143. typedef struct
  144. {
  145. ULONG cjNTFM; // size of NTFM struct, with attached data.
  146. LOFFSET loszFontName; // offset to FontName.
  147. LOFFSET loIFIMETRICS; // offset to IFIMETRICS structure.
  148. ULONG cKernPairs;
  149. LOFFSET loKernPairs; // offset to start of FD_KERNINGPAIR structs.
  150. } NTFMSZ;
  151. typedef struct
  152. {
  153. ULONG ulVersion; // version
  154. NTFMSZ ntfmsz; // size inormation
  155. FLONG flNTFM; // flags [bodind]
  156. EXTTEXTMETRIC etm;
  157. USHORT ausCharWidths[256];
  158. } NTFM, *PNTFM;
  159. // This is value needed to determine if a particular soft font needs
  160. // encoding vector remapping (stolen win31 source code) [bodind]
  161. #define NO_TRANSLATE_CHARSET 200
  162. // Maximum length of font names
  163. #define MAX_FONTNAME 128
  164. // An estimate of average PS font size =~ 33K
  165. #define AVERAGE_FONT_SIZE (33*1024)
  166. /*--------------------------------------------------------------------*\
  167. * The PFB file format is a sequence of segments, each of which has a *
  168. * header part and a data part. The header format, defined in the *
  169. * struct PFBHEADER below, consists of a one byte sanity check number *
  170. * (128) then a one byte segment type and finally a four byte length *
  171. * field for the data following data. The length field is stored in *
  172. * the file with the least significant byte first. *
  173. * *
  174. * The segment types are: *
  175. * 1.) The data is a sequence of ASCII characters. *
  176. * 2.) The data is a sequence of binary characters to be converted *
  177. * to a sequence of pairs of hexadecimal digits. *
  178. * 3.) The last segment in the file. This segment has no length or *
  179. * data fields. *
  180. * *
  181. * The segment types are defined explicitly rather than as an *
  182. * enumerated type because the values for each type are defined by the *
  183. * file format rather than the compiler manipulating them. *
  184. \*--------------------------------------------------------------------*/
  185. #define CHECK_BYTE 128 // first byte of file segment
  186. #define ASCII_TYPE 1 // segment type identifier
  187. #define BINARY_TYPE 2
  188. #define EOF_TYPE 3
  189. // Macro to verify whether a PFBHEADER is valid
  190. #define ValidPfbHeader(p) (*((PBYTE)(p)) == CHECK_BYTE)
  191. // Macro to retrieve the segment type field of PFBHEADER
  192. #define PfbSegmentType(p) (((PBYTE)(p))[1])
  193. // Macro to retrieve the segment length field of PFBHEADER
  194. #define PfbSegmentLength(p) (((DWORD) ((PBYTE)(p))[2] ) | \
  195. ((DWORD) ((PBYTE)(p))[3] << 8) | \
  196. ((DWORD) ((PBYTE)(p))[4] << 16) | \
  197. ((DWORD) ((PBYTE)(p))[5] << 24))
  198. // Size of PFBHEADER = 6 bytes
  199. #define PFBHEADER_SIZE 6