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.

252 lines
8.9 KiB

  1. #ifndef _FONTFACE_
  2. #define _FONTFACE_
  3. class GpFontFile;
  4. class ShapingCache; // implemented in ..\text\uniscribe\shaping
  5. struct ShapingCacheFactory
  6. {
  7. GpStatus Create(const GpFontFace *face);
  8. void Destroy();
  9. ShapingCache *Cache;
  10. };
  11. ///// GpFontFace
  12. //
  13. //
  14. class GpFontFace
  15. {
  16. public:
  17. FontStyle GetFaceStyle(void) const
  18. {
  19. switch (pifi->fsSelection & (FM_SEL_BOLD | FM_SEL_ITALIC))
  20. {
  21. case FM_SEL_BOLD: return FontStyleBold;
  22. case FM_SEL_ITALIC: return FontStyleItalic;
  23. case FM_SEL_BOLD | FM_SEL_ITALIC: return FontStyleBoldItalic;
  24. default: return FontStyleRegular;
  25. }
  26. }
  27. BOOL SimBold() const
  28. {
  29. BOOL ret = FALSE;
  30. if (pifi->dpFontSim)
  31. {
  32. FONTSIM *pfs = (FONTSIM*) ((BYTE*)pifi + pifi->dpFontSim);
  33. ret = (pifi->fsSelection & FM_SEL_ITALIC) ?
  34. (BOOL) pfs->dpBoldItalic : (BOOL) pfs->dpBold;
  35. }
  36. return (ret);
  37. }
  38. BOOL SimItalic() const
  39. {
  40. BOOL ret = FALSE;
  41. if (pifi->dpFontSim)
  42. {
  43. FONTSIM *pfs = (FONTSIM*) ((BYTE*)pifi + pifi->dpFontSim);
  44. ret = (pifi->fsSelection & FM_SEL_BOLD) ?
  45. (BOOL) pfs->dpBoldItalic : (BOOL) pfs->dpItalic;
  46. }
  47. return (ret);
  48. }
  49. void IncGpFontFamilyRef(void) { cGpFontFamilyRef++; }
  50. void DecGpFontFamilyRef(void) { cGpFontFamilyRef--; }
  51. public:
  52. // The following internal class variables are public because they
  53. // are initialised and manipulated by classless code ported from GDI.
  54. // Location of font.
  55. GpFontFile *pff; // pointer to physical font file object
  56. ULONG iFont; // index of the font for IFI or device, 1 based
  57. FLONG flPFE;
  58. // Font data.
  59. GP_IFIMETRICS *pifi; // pointer to ifimetrics
  60. ULONG idifi; // id returned by driver for IFIMETRICS
  61. // information needed to support ETO_GLYPHINDEX mode of ExtTextOut.
  62. ULONG NumGlyphs;
  63. // Ref count for GpFontFamily objects that point to this GpFontFace
  64. ULONG cGpFontFamilyRef;
  65. mutable BYTE lfCharset;
  66. static int CALLBACK EnumFontFamExProcA(
  67. const ENUMLOGFONTEXA *lpelfe, // logical-font data
  68. const NEWTEXTMETRICEXA *lpntme, // physical-font data
  69. int FontType, // type of font
  70. LPARAM lParam // application-defined data
  71. );
  72. static int CALLBACK EnumFontFamExProcW(
  73. const ENUMLOGFONTEXW *lpelfe, // logical-font data
  74. const NEWTEXTMETRICEXW *lpntme, // physical-font data
  75. int FontType, // type of font
  76. LPARAM lParam // application-defined data
  77. );
  78. // Text support
  79. UINT16 GetDesignEmHeight() const {return pifi->fwdUnitsPerEm;}
  80. UINT16 GetDesignCellAscent() const {return pifi->fwdWinAscender;}
  81. UINT16 GetDesignCellDescent() const {return pifi->fwdWinDescender;}
  82. UINT16 GetDesignLineSpacing() const {return max(pifi->fwdMacAscender-pifi->fwdMacDescender+pifi->fwdMacLineGap, pifi->fwdWinAscender+pifi->fwdWinDescender);}
  83. UINT16 GetDesignUnderscoreSize() const {return pifi->fwdUnderscoreSize;}
  84. INT16 GetDesignUnderscorePosition() const {return pifi->fwdUnderscorePosition;}
  85. UINT16 GetDesignStrikeoutSize() const {return pifi->fwdStrikeoutSize;}
  86. INT16 GetDesignStrikeoutPosition() const {return pifi->fwdStrikeoutPosition;}
  87. GpStatus GetFontData(UINT32 tag,
  88. INT* size,
  89. BYTE** pjTable) const;
  90. void ReleaseFontData() const;
  91. BYTE GetCharset(HDC hdc) const;
  92. const IntMap<UINT16> &GetCmap() const {return *Cmap;}
  93. const IntMap<UINT16> &GetDesignAdvance() const {return *DesignAdvance;}
  94. const IntMap<UINT16> *GetDesignVerticalAdvance() const {return DesignVerticalAdvance;}
  95. BOOL RequiresFullTextImager() const {return RequiresFullText;}
  96. UINT16 GetMissingGlyph() const {return MissingGlyph;}
  97. UINT16 GetBlankGlyph() const {return BlankGlyph;}
  98. BYTE *GetGSUB() const {return Gsub;}
  99. BYTE *GetGPOS() const {return Gpos;}
  100. BYTE *GetGDEF() const {return Gdef;}
  101. BYTE *GetMort() const {return Mort;}
  102. UINT16 GetVerticalSubstitutionCount() const {return VerticalSubstitutionCount;}
  103. const UINT16 *GetVerticalSubstitutionOriginals() const {return VerticalSubstitutionOriginals;}
  104. const UINT16 *GetVerticalSubstitutionSubstitutions() const {return VerticalSubstitutionSubstitutions;}
  105. void GetGlyphDesignAdvances(
  106. IN const UINT16 *glyphs, //
  107. IN INT glyphCount, //
  108. IN INT style, // Causes adjustment for algorithmic style emulation
  109. IN BOOL vertical, // Use vtmx, not htmx
  110. IN REAL tracking, // Expansion factor
  111. OUT UINT16 *advances //
  112. ) const;
  113. void GetGlyphDesignAdvancesIdeal(
  114. IN const UINT16 *glyphs, //
  115. IN INT glyphCount, //
  116. IN INT style, // Causes adjustment for algorithmic style emulation
  117. IN BOOL vertical, // Use vtmx, not htmx
  118. IN REAL designToIdeal, // Scale factor for each advance width
  119. IN REAL tracking, // Expansion factor
  120. OUT INT *advances //
  121. ) const;
  122. inline ShapingCache *GetShapingCache() const
  123. {
  124. return Shaping.Cache;
  125. }
  126. void FreeImagerTables();
  127. BOOL IsAliasName()
  128. {
  129. BOOL bOk = FALSE;
  130. if (pifi->flInfo & FM_INFO_FAMILY_EQUIV)
  131. {
  132. bOk = TRUE;
  133. }
  134. return bOk;
  135. }
  136. WCHAR * GetAliasName()
  137. {
  138. size_t length;
  139. length = UnicodeStringLength((WCHAR *)(((BYTE*) pifi) + pifi->dpwszFamilyName)) + 1;
  140. if (!(pifi->flInfo & FM_INFO_FAMILY_EQUIV))
  141. {
  142. return (WCHAR *) NULL;
  143. }
  144. return((WCHAR *)(((BYTE*) pifi) + pifi->dpwszFamilyName) + length);
  145. }
  146. BOOL IsPrivate() const { return bPrivateFace;}
  147. BOOL IsSymbol() const { return bSymbol;}
  148. void SetPrivate(BOOL bPrivate) { bPrivateFace = bPrivate;}
  149. void SetSymbol(BOOL symbol) { bSymbol = symbol;}
  150. BOOL InitializeImagerTables();
  151. void SetSupportedCodePages(__int64 codePages)
  152. {
  153. SupportedCodePages = ((codePages & 0xFF00000000000000) >> 24);
  154. SupportedCodePages |= ((codePages & 0x00FF000000000000) >> 8 );
  155. SupportedCodePages |= ((codePages & 0x0000FF0000000000) << 8 );
  156. SupportedCodePages |= ((codePages & 0x000000FF00000000) << 24);
  157. SupportedCodePages |= ((codePages & 0x00000000FF000000) >> 24);
  158. SupportedCodePages |= ((codePages & 0x0000000000FF0000) >> 8 );
  159. SupportedCodePages |= ((codePages & 0x000000000000FF00) << 8 );
  160. SupportedCodePages |= ((codePages & 0x00000000000000FF) << 24);
  161. }
  162. BOOL IsCodePageSupported(UINT codePage);
  163. private:
  164. mutable IntMap<UINT16> *Cmap;
  165. mutable IntMap<UINT16> *DesignAdvance;
  166. mutable IntMap<UINT16> *DesignVerticalAdvance;
  167. mutable IntMap<UINT16> *DesignTopSidebearing;
  168. mutable ShapingCacheFactory Shaping;
  169. mutable BOOL RequiresFullText;
  170. mutable UINT16 MissingGlyph;
  171. mutable UINT16 BlankGlyph;
  172. BOOL bPrivateFace;
  173. mutable BOOL bSymbol;
  174. mutable __int64 SupportedCodePages;
  175. mutable BYTE *Gsub; // OTL glyph substitution table
  176. mutable BYTE *Gpos; // OTL glyph positioning table
  177. mutable BYTE *Gdef; // OTL glyph definition table
  178. mutable BYTE *Mort; // legacy vertical substitution table
  179. mutable UINT16 VerticalSubstitutionCount; // Number of substitutable glyphs
  180. mutable const UINT16 *VerticalSubstitutionOriginals; // Pointer into cached GSUB
  181. mutable const UINT16 *VerticalSubstitutionSubstitutions; // Pointer into cached GSUB
  182. };
  183. #endif // FONTFACE