Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

272 righe
5.9 KiB

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