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.

175 lines
4.9 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * font.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Font and text related header file
  12. *
  13. * Revision History:
  14. *
  15. * 05/05/1999 ikkof
  16. * Added more constructors.
  17. *
  18. * 12/94/1998 davidx
  19. * Created it.
  20. *
  21. \**************************************************************************/
  22. #ifndef _FONT_HPP
  23. #define _FONT_HPP
  24. //
  25. // Represent a font object
  26. //
  27. // !!!
  28. // In the current version, we'll continue to use the existing
  29. // WFC font related classes. In the managed interface layer,
  30. // we can extract an HFONT out of the WFC Font object. Internally,
  31. // we'll use GpFont, which is just an HFONT.
  32. //
  33. class GpFont : public GpObject
  34. {
  35. protected:
  36. VOID SetValid(BOOL valid)
  37. {
  38. GpObject::SetValid(valid ? ObjectTagFont : ObjectTagInvalid);
  39. }
  40. public:
  41. GpFont() // used by object factory
  42. {
  43. SetValid(TRUE); // default is valid
  44. }
  45. GpFont(HDC hdc);
  46. GpFont(HDC hdc, LOGFONTW *logfont);
  47. GpFont(HDC hdc, LOGFONTA *logfont);
  48. GpFont(const GpFont &font)
  49. {
  50. Family = font.Family;
  51. EmSize = font.EmSize;
  52. Style = font.Style;
  53. SizeUnit = font.SizeUnit;
  54. SetValid(TRUE); // default is valid
  55. }
  56. GpFont(
  57. REAL size,
  58. const GpFontFamily *family,
  59. INT style = FontStyleRegular,
  60. Unit unit = UnitPoint
  61. ) ;
  62. ~GpFont()
  63. {
  64. }
  65. GpFont* Clone() const
  66. {
  67. return new GpFont(*this);
  68. }
  69. GpStatus GetLogFontA(GpGraphics * g, LOGFONTA * lfA);
  70. GpStatus GetLogFontW(GpGraphics * g, LOGFONTW * lfW);
  71. BOOL IsValid() const
  72. {
  73. // If the font came from a different version of GDI+, its tag
  74. // will not match, and it won't be considered valid.
  75. return ((Family != NULL) && GpObject::IsValid(ObjectTagFont));
  76. }
  77. const GpFontFamily *GetFamily() const {return Family;}
  78. REAL GetEmSize() const {return EmSize;}
  79. GpStatus SetEmSize(REAL size) {EmSize = size; UpdateUid(); return Ok;}
  80. INT GetStyle() const {return Style;}
  81. GpStatus SetStyle(INT newStyle) {Style=newStyle; UpdateUid(); return Ok;}
  82. Unit GetUnit() const {return SizeUnit;}
  83. GpStatus SetUnit(Unit newUnit) {SizeUnit=newUnit; UpdateUid(); return Ok;}
  84. GpFontFace *GetFace() const
  85. {
  86. return Family ? Family->GetFace(Style) : NULL;
  87. }
  88. GpStatus GetHeight(REAL dpi, REAL *height) const;
  89. GpStatus GetHeight(const GpGraphics *graphics, REAL *height) const;
  90. GpStatus GetHeightAtWorldEmSize(REAL worldEmSize, REAL *height) const;
  91. UINT16 GetDesignEmHeight() const {return GetFace()->GetDesignEmHeight();}
  92. UINT16 GetDesignCellAscent() const {return GetFace()->GetDesignCellAscent();}
  93. UINT16 GetDesignCellDescent() const {return GetFace()->GetDesignCellDescent();}
  94. UINT16 GetDesignLineSpacing() const {return GetFace()->GetDesignLineSpacing();}
  95. UINT16 GetDesignUnderscoreSize() const {return GetFace()->GetDesignUnderscoreSize();}
  96. INT16 GetDesignUnderscorePosition() const {return GetFace()->GetDesignUnderscorePosition();}
  97. UINT16 GetDesignStrikeoutSize() const {return GetFace()->GetDesignStrikeoutSize();}
  98. INT16 GetDesignStrikeoutPosition() const {return GetFace()->GetDesignStrikeoutPosition();}
  99. virtual ObjectType GetObjectType() const { return ObjectTypeFont; }
  100. virtual UINT GetDataSize() const;
  101. virtual GpStatus GetData(IStream * stream) const;
  102. virtual GpStatus SetData(const BYTE * dataBuffer, UINT size);
  103. private:
  104. VOID InitializeFromDc(HDC hdc);
  105. const GpFontFamily *Family;
  106. REAL EmSize;
  107. INT Style;
  108. Unit SizeUnit;
  109. };
  110. class GpGlyphPath : public _PATHOBJ
  111. {
  112. public:
  113. BOOL hasBezier;
  114. INT pointCount;
  115. GpPointF *points;
  116. BYTE *types;
  117. GpGlyphPath() {};
  118. ~GpGlyphPath() {};
  119. BOOL IsValid() const { return (pointCount ? (points && types) : TRUE); }
  120. BOOL IsEmpty() const { return (pointCount ? FALSE : TRUE); }
  121. GpStatus
  122. CopyPath(GpPath *path);
  123. };
  124. // wrappers to protect against possible exception
  125. // on accessing data in memory mapped file
  126. static inline void MapCopy(void *pDst,
  127. const void *pSrc,
  128. size_t size,
  129. Status* pStatus)
  130. {
  131. __try
  132. {
  133. memcpy(pDst, pSrc, size);
  134. }
  135. __except (EXCEPTION_EXECUTE_HANDLER)
  136. {
  137. *pStatus = GenericError;
  138. }
  139. }
  140. #endif // !_FONT_HPP