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.

272 lines
7.0 KiB

  1. #ifndef _TEXTIMAGER_HPP
  2. #define _TEXTIMAGER_HPP
  3. #define DriverStringOptionsMetaPlay 0x80000000
  4. class GpTextImager
  5. {
  6. friend class FullTextImager;
  7. public:
  8. GpTextImager() : IsMetaFileRecording(FALSE) {};
  9. virtual ~GpTextImager() {};
  10. virtual Status GetStatus() const = 0;
  11. virtual GpStatus Draw(GpGraphics *graphics, const PointF *origin) = 0;
  12. virtual GpStatus AddToPath(GpPath *path, const PointF *origin) = 0;
  13. virtual GpStatus Measure(
  14. GpGraphics *graphics,
  15. REAL *nearGlyphEdge, // Excudes overhang
  16. REAL *farGlyphEdge, // Excludes overhang
  17. REAL *textDepth,
  18. INT *codepointsFitted,
  19. INT *linesFilled
  20. ) = 0;
  21. virtual GpStatus MeasureRanges(
  22. GpGraphics *graphics,
  23. const PointF *origin,
  24. GpRegion **regions
  25. ) = 0;
  26. static void CleanupTextImager();
  27. BOOL &GetMetaFileRecordingFlag()
  28. {
  29. return IsMetaFileRecording;
  30. }
  31. protected:
  32. BOOL IsMetaFileRecording;
  33. };
  34. ///// newTextImager
  35. //
  36. // Creates a new text imager.
  37. //
  38. // If any form of error occurs during the imager creation, an error status
  39. // is returned, and any allocated memory is released.
  40. GpStatus newTextImager(
  41. const WCHAR *string,
  42. INT length,
  43. REAL width,
  44. REAL height,
  45. const GpFontFamily *family,
  46. INT style,
  47. REAL size,
  48. const GpStringFormat *format,
  49. const GpBrush *brush,
  50. GpTextImager **imager,
  51. BOOL singleUse // Enables use of simple formatter when no format passed
  52. );
  53. ///// ReadCmap - in engine\text\imager\cmap.cpp
  54. GpStatus ReadCmap(
  55. BYTE *cmapTable,
  56. INT cmapLength,
  57. IntMap<UINT16> *cmap,
  58. BOOL *bSymbol
  59. );
  60. ///// ReadMtx - in engine\text\imager\hmtx.cpp
  61. //
  62. // Reads hmtx or vmtx table
  63. GpStatus ReadMtx(
  64. BYTE *Mtx,
  65. UINT MtxLength,
  66. INT numGlyphs,
  67. INT numberOfLongMetrics,
  68. IntMap<UINT16> *designAdvance
  69. );
  70. GpStatus ReadMtxSidebearing(
  71. BYTE *mtx,
  72. UINT mtxLength,
  73. INT numGlyphs,
  74. INT numberOfLongMetrics,
  75. IntMap<UINT16> *sidebearing
  76. );
  77. ///// in engine\text\uniscribe\gsub.cxx
  78. //
  79. // Examine gsub or mort for 'vert' features and supported scripts
  80. void LoadVerticalSubstitution(
  81. const BYTE *gsub,
  82. UINT16 *substitutionCount,
  83. const UINT16 **originals, // returned as pointer into gsub, not endian converted
  84. const UINT16 **substitutions // returned as pointer into gsub, not endian converted
  85. );
  86. void LoadMortVerticalSubstitution(
  87. BYTE *mort,
  88. UINT16 *substitutionCount,
  89. const UINT16 **originals, // returned as pointer into mort, not endian converted
  90. const UINT16 **substitutions // returned as pointer into mort, not endian converted
  91. );
  92. void SubstituteVerticalGlyphs(
  93. UINT16 *glyphs, // InOut
  94. UINT16 glyphCount,
  95. UINT16 substitutionCount,
  96. const UINT16 *originals,
  97. const UINT16 *substitutions
  98. );
  99. /**************************************************************************\
  100. *
  101. * SplitTransform:
  102. *
  103. * Separates a transform into the sequence
  104. *
  105. * o scale x always positive, y positive or negative
  106. * o rotate 0 - 2pi
  107. * o shear along original x (as a positive or negative factor of y)
  108. * o translate any x,y
  109. *
  110. * Arguments:
  111. *
  112. * IN transform
  113. * OUT scale
  114. * OUT rotate
  115. * OUT shear
  116. * OUT translate
  117. *
  118. * Return Value:
  119. *
  120. * none
  121. *
  122. * Created:
  123. *
  124. * 06/18/99 dbrown
  125. *
  126. * !!!
  127. * SplitTransform should probably be in matrix.hpp
  128. *
  129. \**************************************************************************/
  130. void SplitTransform(
  131. const GpMatrix &matrix,
  132. PointF &scale,
  133. REAL &rotate,
  134. REAL &shear,
  135. PointF &translate
  136. );
  137. ///// DetermineStringComplexity
  138. //
  139. // Returns whether string contains complex script characters and/or digits.
  140. void DetermineStringComplexity(
  141. const UINT16 *string,
  142. INT length,
  143. BOOL *complex,
  144. BOOL *digitSeen
  145. );
  146. // SetTextLinesAntialiasMode
  147. // make underline/strikeout/path rendering consistent with text antialiasing mode
  148. // turn it on for AntiAlias and AntiAliasGridFit (excluding 'gasp' table case)
  149. class SetTextLinesAntialiasMode
  150. {
  151. GpGraphics * Graphics;
  152. BOOL OldMode;
  153. public:
  154. SetTextLinesAntialiasMode(GpGraphics * graphics, const GpFaceRealization * faceRealization)
  155. : Graphics(0), OldMode(0)
  156. {
  157. SetAAMode(graphics, faceRealization);
  158. }
  159. void SetAAMode(GpGraphics * graphics, const GpFaceRealization * faceRealization)
  160. {
  161. ASSERT(!Graphics); // otherwise we lose old AA mode
  162. Graphics = graphics;
  163. if (!Graphics)
  164. {
  165. ASSERT(!faceRealization);
  166. }
  167. else
  168. {
  169. OldMode = Graphics->GetAntiAliasMode();
  170. ASSERT(faceRealization);
  171. TextRenderingHint hint = faceRealization->IsPathFont()
  172. ? Graphics->GetTextRenderingHintInternal()
  173. : faceRealization->RealizationMethod();
  174. BOOL newMode = FALSE;
  175. if (hint == TextRenderingHintAntiAlias)
  176. newMode = TRUE;
  177. else if (hint == TextRenderingHintAntiAliasGridFit)
  178. {
  179. if (faceRealization->IsPathFont())
  180. newMode = TRUE;
  181. else
  182. {
  183. if (faceRealization->IsHorizontalTransform() || faceRealization->IsVerticalTransform())
  184. newMode = FALSE; // otherwise underline looks fuzzy
  185. else
  186. newMode = TRUE;
  187. }
  188. }
  189. Graphics->SetAntiAliasMode(newMode);
  190. }
  191. }
  192. ~SetTextLinesAntialiasMode()
  193. {
  194. if (Graphics)
  195. Graphics->SetAntiAliasMode(OldMode);
  196. }
  197. }; // class SetTextLinesAntialiasMode
  198. // This class is used if we call public GpGraphics methods
  199. // from another public GpGraphics method to avoid extra GDI+ records
  200. // We have to set g->Metafile to NULL so we don't record all the GDI+ records
  201. // in the metafile again -- only the down-level ones.
  202. class EmfPlusDisabler
  203. {
  204. IMetafileRecord ** MetafileRef;
  205. IMetafileRecord * SavedMetafile;
  206. public:
  207. EmfPlusDisabler(IMetafileRecord ** metafileRef)
  208. {
  209. MetafileRef = metafileRef;
  210. SavedMetafile = *MetafileRef;
  211. *MetafileRef = 0;
  212. }
  213. ~EmfPlusDisabler()
  214. {
  215. *MetafileRef = SavedMetafile;
  216. }
  217. }; // class EmfPlusDisabler
  218. #endif // _TEXTIMAGER_HPP