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.

174 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1996 - 1999 Microsoft Corporation
  3. Module Name:
  4. download.h
  5. Abstract:
  6. Information required to download fonts to a printer: either an
  7. existing softfont, or cacheing of GDI fonts (esp. TT).
  8. Environment:
  9. Windows NT Unidrv driver
  10. Revision History:
  11. 12/23/96 -ganeshp-
  12. Created
  13. dd-mm-yy -author-
  14. description
  15. --*/
  16. #ifndef _DOWNLOAD_H
  17. #define _DOWNLOAD_H
  18. //
  19. // GLYPHLIST structure. This structure hold the start and end glyph ids.
  20. //
  21. #define INVALIDGLYPHID 0xffffffff
  22. #define HASHTABLESIZE_1 257 //Used if NumGlyphs is < 512
  23. #define HASHTABLESIZE_2 521 //Used if NmGlyhs is >= 512 && < 1024
  24. #define HASHTABLESIZE_3 1031 //Used if NmGlyhs is >= 1024
  25. //
  26. // Hash Table entry for glyphs. The entry has basically TT Glyph Handle and
  27. // Downloaded FontIds and DL glyph ID. The hash table is an array of these
  28. // entries. In the case of a Hit a new entry will be added as linked list
  29. // off that entry.
  30. //
  31. typedef struct _DLGLYPH //Size is 16 Bytes.
  32. {
  33. HGLYPH hTTGlyph; // GDI glyph handle.
  34. WORD wDLFontId; // DL Font index. Bounded Fonts.
  35. WORD wDLGlyphID; // Download Glyph ID of unbounded fonts.
  36. WORD wWidth; // Width of the Glyph.
  37. WCHAR wchUnicode; // Reserved for padding.
  38. struct _DLGLYPH *pNext; // Next Glyph
  39. }DLGLYPH, *PDLGLYPH;
  40. // The Glyphs are stored in Chunks, to optimize on allocation and
  41. // deallocations.The first chunk is the base chunk and used as Hash table.
  42. // The subsequent chunks are allocated when a collision occurs in the hash
  43. // table. All the non base chunks has half the number of Glyphs as that of
  44. // base chunk (cEntries is intialized to cHashTableEntries/2). The base hash
  45. // table is dl_map.GlyphTab.pGlyph. we should free this pointer for base chunk.
  46. // Base hash table is allocated in BInitDLMAP() function, which initialize the
  47. // DL_MAP.
  48. typedef struct _GLYPHTAB
  49. {
  50. struct _GLYPHTAB *pGLTNext; // Next Chunk of Glyphs
  51. PDLGLYPH pGlyph; // Pointer to Next Glyph.
  52. INT cEntries; // Number of Entries Remaining.
  53. // Not Used in Base Chunk.
  54. }GLYPHTAB;
  55. //
  56. // The DL_MAP structure provides a mapping between the iUniq value in
  57. // FONTOBJs and our internal information. Basically, we need to decide
  58. // whether we have seen this font before, and if so, whether it was
  59. // downloaded or left as a GDI font.
  60. //
  61. //
  62. // NOTE: The cGlyphs field has another use. It is used to mark a bad DL_MAP.
  63. // If it is -1, then this DL_MAP shouldn't be used. All other fields will
  64. // be set to 0.
  65. //
  66. typedef struct _DL_MAP
  67. {
  68. ULONG iUniq; // FONTOBJ.iUniq
  69. ULONG_PTR iTTUniq; // FONTOBJ.iTTUniq
  70. SHORT cGlyphs; // Num of DL glyphs with current softfont
  71. WORD cTotalGlyphs; // Total Number of glyphs with this TT font
  72. WORD wMaxGlyphSize; // NumBytes in the bitmap for largest Glyph
  73. WORD cHashTableEntries; // Number of entries in the HASH table.
  74. WORD wFirstDLGId; // Start DL Glyph ID.
  75. WORD wLastDLGId; // End ID of the List. -1 if no END id
  76. WORD wNextDLGId; // Next DL Glyph ID to be downloaded.
  77. WORD wBaseDLFontid; // Downloaded Base font Id.
  78. WORD wCurrFontId; // Current Font ID to be used.
  79. WORD wFlags; // Different Flags.
  80. FONTMAP *pfm; // The real down load info
  81. GLYPHTAB GlyphTab; // Glyph Hash Table.It's Linked
  82. // list of Glyph Chunks.
  83. } DL_MAP;
  84. //
  85. // DL_MAP flags.
  86. //
  87. #define DLM_BOUNDED 0x0001 // Soft font is bounded.
  88. #define DLM_UNBOUNDED 0x0002 // Soft font is unbounded.
  89. //
  90. // The above is formed into an array of DL_MAP_CHUNK entries, and this
  91. // group of storage is linked into a linked list of such entries. Typically,
  92. // there will be only one, however we can cope with more.
  93. //
  94. #define DL_MAP_CHUNK 8
  95. typedef struct _DML
  96. {
  97. struct _DML *pDMLNext; // An array of map information
  98. INT cEntries; // Next in our chain, 0 in last
  99. DL_MAP adlm[ DL_MAP_CHUNK ]; // Number of valid entries.
  100. } DL_MAP_LIST;
  101. /*
  102. * We need to map glyph handles to byte to send to printer. We are given
  103. * the glyph handle, but need to send the byte instead.
  104. */
  105. typedef struct
  106. {
  107. HGLYPH hg; /* The glyph to print */
  108. WCHAR wchUnicode;
  109. int iByte; /* What to send to the printer */
  110. } HGLYPH_MAP;
  111. /*
  112. * Random constants.
  113. */
  114. #define PCL_FONT_OH 2048 /* Overhead bytes per download font */
  115. #define PCL_PITCH_ADJ 2 /* Adjustment factor for proportional */
  116. /*
  117. * macros
  118. */
  119. #define SWAPW(a) (USHORT)(((BYTE)((a) >> 8)) | ((BYTE)(a) << 8))
  120. #define SWAPWINC(a) SWAPW(*(a)); a++
  121. #define FONTDOWNLOADED(pdm) ( ((pdm)->pfm) && \
  122. ((pdm)->pfm->flFlags & \
  123. (FM_SENT | FM_GEN_SFONT)) )
  124. #define GLYPHDOWNLOADED(pdlg) ( ((pdlg)->hTTGlyph != HGLYPH_INVALID) )
  125. //
  126. // Download Mode to identity base softfont or secondary soft font downloading.
  127. //
  128. #define DL_BASE_SOFT_FONT 1
  129. #define DL_SECONDARY_SOFT_FONT 2
  130. #define MIN_GLYPHS_PER_SOFTFONT 64 // Minimum glyphs per softfont
  131. #endif _DOWNLOAD_H //!_DOWNLOAD_H