Source code of Windows XP (NT5)
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.

273 lines
5.7 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Abstract:
  6. *
  7. * Font family API related declarations
  8. *
  9. * Revision History:
  10. *
  11. *
  12. * 06/30/1999 cameronb
  13. * Created it.
  14. *
  15. \**************************************************************************/
  16. #ifndef _GDIPLUS_FONT_FAMILY_H
  17. #define _GDIPLUS_FONT_FAMILY_H
  18. inline
  19. FontFamily::FontFamily() :
  20. nativeFamily (NULL),
  21. lastResult (Ok)
  22. {
  23. }
  24. inline
  25. FontFamily::FontFamily(
  26. IN const WCHAR* name,
  27. IN const FontCollection* fontCollection
  28. )
  29. {
  30. nativeFamily = NULL;
  31. lastResult = DllExports::GdipCreateFontFamilyFromName(
  32. name,
  33. fontCollection ? fontCollection->nativeFontCollection : NULL,
  34. &nativeFamily
  35. );
  36. #ifndef DCR_USE_NEW_135429
  37. if ((INT) lastResult >= 10)
  38. lastResult = NotFound;
  39. #endif
  40. }
  41. // private method
  42. inline
  43. FontFamily::FontFamily(
  44. IN GpFontFamily *nativeOrig,
  45. IN Status status
  46. )
  47. {
  48. lastResult = status;
  49. nativeFamily = nativeOrig;
  50. }
  51. // Generic font family access
  52. inline const FontFamily *
  53. FontFamily::GenericSansSerif()
  54. {
  55. if (GenericSansSerifFontFamily != NULL)
  56. {
  57. return GenericSansSerifFontFamily;
  58. }
  59. GenericSansSerifFontFamily =
  60. (FontFamily*) GenericSansSerifFontFamilyBuffer;
  61. GenericSansSerifFontFamily->lastResult =
  62. DllExports::GdipGetGenericFontFamilySansSerif(
  63. &(GenericSansSerifFontFamily->nativeFamily)
  64. );
  65. #ifndef DCR_USE_NEW_135429
  66. if ((INT) GenericSansSerifFontFamily->lastResult >= 10)
  67. GenericSansSerifFontFamily->lastResult = NotFound;
  68. #endif
  69. return GenericSansSerifFontFamily;
  70. }
  71. inline const FontFamily *
  72. FontFamily::GenericSerif()
  73. {
  74. if (GenericSerifFontFamily != NULL)
  75. {
  76. return GenericSerifFontFamily;
  77. }
  78. GenericSerifFontFamily =
  79. (FontFamily*) GenericSerifFontFamilyBuffer;
  80. GenericSerifFontFamily->lastResult =
  81. DllExports::GdipGetGenericFontFamilySerif(
  82. &(GenericSerifFontFamily->nativeFamily)
  83. );
  84. #ifndef DCR_USE_NEW_135429
  85. if ((INT) GenericSerifFontFamily->lastResult >= 10)
  86. GenericSerifFontFamily->lastResult = NotFound;
  87. #endif
  88. return GenericSerifFontFamily;
  89. }
  90. inline const FontFamily *
  91. FontFamily::GenericMonospace()
  92. {
  93. if (GenericMonospaceFontFamily != NULL)
  94. {
  95. return GenericMonospaceFontFamily;
  96. }
  97. GenericMonospaceFontFamily =
  98. (FontFamily*) GenericMonospaceFontFamilyBuffer;
  99. GenericMonospaceFontFamily->lastResult =
  100. DllExports::GdipGetGenericFontFamilyMonospace(
  101. &(GenericMonospaceFontFamily->nativeFamily)
  102. );
  103. #ifndef DCR_USE_NEW_135429
  104. if ((INT) GenericMonospaceFontFamily->lastResult >= 10)
  105. GenericMonospaceFontFamily->lastResult = NotFound;
  106. #endif
  107. return GenericMonospaceFontFamily;
  108. }
  109. inline FontFamily::~FontFamily()
  110. {
  111. DllExports::GdipDeleteFontFamily (nativeFamily);
  112. }
  113. inline FontFamily *
  114. FontFamily::Clone() const
  115. {
  116. GpFontFamily * clonedFamily = NULL;
  117. SetStatus(DllExports::GdipCloneFontFamily (nativeFamily, &clonedFamily));
  118. return new FontFamily(clonedFamily, lastResult);
  119. }
  120. inline Status
  121. FontFamily::GetFamilyName(
  122. IN WCHAR name[LF_FACESIZE],
  123. IN LANGID language
  124. ) const
  125. {
  126. return SetStatus(DllExports::GdipGetFamilyName(nativeFamily,
  127. name,
  128. language));
  129. }
  130. inline BOOL
  131. FontFamily::IsStyleAvailable(IN INT style) const
  132. {
  133. BOOL StyleAvailable;
  134. Status status;
  135. status = SetStatus(DllExports::GdipIsStyleAvailable(nativeFamily, style, &StyleAvailable));
  136. if (status != Ok)
  137. StyleAvailable = FALSE;
  138. return StyleAvailable;
  139. }
  140. inline UINT16
  141. FontFamily::GetEmHeight(IN INT style) const
  142. {
  143. UINT16 EmHeight;
  144. SetStatus(DllExports::GdipGetEmHeight(nativeFamily, style, &EmHeight));
  145. return EmHeight;
  146. }
  147. inline UINT16
  148. FontFamily::GetCellAscent(IN INT style) const
  149. {
  150. UINT16 CellAscent;
  151. SetStatus(DllExports::GdipGetCellAscent(nativeFamily, style, &CellAscent));
  152. return CellAscent;
  153. }
  154. inline UINT16
  155. FontFamily::GetCellDescent(IN INT style) const
  156. {
  157. UINT16 CellDescent;
  158. SetStatus(DllExports::GdipGetCellDescent(nativeFamily, style, &CellDescent));
  159. return CellDescent;
  160. }
  161. inline UINT16
  162. FontFamily::GetLineSpacing(IN INT style) const
  163. {
  164. UINT16 LineSpacing;
  165. SetStatus(DllExports::GdipGetLineSpacing(nativeFamily, style, &LineSpacing));
  166. return LineSpacing;
  167. }
  168. #ifdef TEXTV2
  169. // The following APIs return data from the font OS/2 table
  170. inline INT16
  171. FontFamily::GetTypographicAscent(IN INT style) const
  172. {
  173. INT16 TypographicAscent;
  174. SetStatus(DllExports::GdipGetTypographicAscent(nativeFamily, style, &TypographicAscent));
  175. return TypographicAscent;
  176. }
  177. inline INT16
  178. FontFamily::GetTypographicDescent(IN INT style) const
  179. {
  180. INT16 TypographicDescent;
  181. SetStatus(DllExports::GdipGetTypographicDescent(nativeFamily, style, &TypographicDescent));
  182. return TypographicDescent;
  183. }
  184. inline INT16
  185. FontFamily::GetTypographicLineGap(IN INT style) const
  186. {
  187. INT16 TypographicLineGap;
  188. SetStatus(DllExports::GdipGetTypographicLineGap(nativeFamily, style, &TypographicLineGap));
  189. return TypographicLineGap;
  190. }
  191. #endif
  192. ///////////////////////////////////////////////////////////
  193. // GetLastStatus - return last error code and clear error code
  194. inline Status
  195. FontFamily::GetLastStatus() const
  196. {
  197. Status lastStatus = lastResult;
  198. lastResult = Ok;
  199. return lastStatus;
  200. }
  201. // protected method
  202. inline Status
  203. FontFamily::SetStatus(Status status) const
  204. {
  205. if (status != Ok)
  206. return (lastResult = status);
  207. else
  208. return status;
  209. }
  210. #endif