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.

116 lines
3.6 KiB

  1. ///// FastTextImager
  2. //
  3. // Handles common case string measurement and display
  4. const INT FAST_TEXT_PREALLOCATED_CHARACTERS = 64;
  5. typedef AutoBuffer<UINT16, FAST_TEXT_PREALLOCATED_CHARACTERS> Uint16StackBuffer;
  6. typedef AutoBuffer<INT, FAST_TEXT_PREALLOCATED_CHARACTERS> IntStackBuffer;
  7. class FastTextImager
  8. {
  9. public:
  10. GpStatus Initialize(
  11. GpGraphics *graphics,
  12. const WCHAR *string,
  13. INT length,
  14. const RectF &layoutRectangle,
  15. const GpFontFamily *family,
  16. INT style,
  17. REAL emSize, // Preconverted to world units
  18. const GpStringFormat *format,
  19. const GpBrush *brush
  20. );
  21. GpStatus MeasureString(
  22. RectF *boundingBox,
  23. INT *codepointsFitted,
  24. INT *linesFilled
  25. );
  26. GpStatus DrawString();
  27. private:
  28. GpStatus RemoveHotkeys();
  29. GpStatus FastLayoutString();
  30. GpStatus DrawFontStyleLine(
  31. const PointF *baselineOrigin, // base line origin in device unit
  32. REAL baselineLength, // base line length in device unit
  33. INT style // font styles
  34. );
  35. void FastAdjustGlyphPositionsProportional(
  36. IN const INT *hintedWidth, // 28.4 device
  37. OUT INT *x, // 28.4 device Initial x
  38. OUT IntStackBuffer &dx, // 32.0 device Glyph advances
  39. OUT const UINT16 **displayGlyphs, // First displayable glyph
  40. OUT INT *displayGlyphCount,
  41. OUT INT *leadingBlankCount
  42. );
  43. void GetWorldTextRectangleOrigin(
  44. PointF &origin
  45. );
  46. void GetDeviceBaselineOrigin(
  47. IN GpFaceRealization &faceRealization,
  48. OUT PointF &origin
  49. );
  50. GpStatus FastDrawGlyphsGridFit(
  51. GpFaceRealization &faceRealization
  52. );
  53. GpStatus FastDrawGlyphsNominal(
  54. GpFaceRealization &faceRealization
  55. );
  56. // Initialisation parameters
  57. GpGraphics *Graphics;
  58. const UINT16 *String;
  59. INT Length; // Measured, if necessary
  60. RectF LayoutRectangle;
  61. const GpFontFamily *Family;
  62. INT Style;
  63. REAL EmSize; // In world units
  64. const GpStringFormat *Format;
  65. const GpBrush *Brush;
  66. // Derived. All are set if Initialize succeeds
  67. INT FormatFlags;
  68. StringAlignment Alignment;
  69. GpFontFace *Face;
  70. GpMatrix WorldToDevice;
  71. REAL LeftMargin;
  72. REAL RightMargin;
  73. INT OverflowAvailable; // Available for advance width expansion 32.0
  74. REAL LeftOffset; // Allowance to reduce adjustment
  75. INT GlyphCount;
  76. REAL TotalWorldAdvance;
  77. GpMatrix FontTransform;
  78. REAL LineLengthLimit;
  79. REAL WorldToDeviceX;
  80. REAL WorldToDeviceY;
  81. UINT16 BlankGlyph;
  82. UINT16 DesignEmHeight;
  83. REAL CellHeight;
  84. INT NominalToBaselineScale; // 16.16
  85. TextRenderingHint TextRendering;
  86. INT HotkeyPosition;
  87. // Auto buffers common to drawing and measurement
  88. AutoBuffer<UINT16, FAST_TEXT_PREALLOCATED_CHARACTERS> Glyphs;
  89. AutoBuffer<UINT16, FAST_TEXT_PREALLOCATED_CHARACTERS> NominalWidths; // 16.0
  90. };