• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 #ifndef _GDIPLUS_FONT_FAMILY_H
16 #define _GDIPLUS_FONT_FAMILY_H
17 
18 inline
FontFamily()19 FontFamily::FontFamily() :
20     nativeFamily (NULL),
21     lastResult    (Ok)
22 {
23 }
24 
25 inline
FontFamily(IN const WCHAR * name,IN const FontCollection * fontCollection)26 FontFamily::FontFamily(
27     IN const WCHAR*          name,
28     IN const FontCollection* fontCollection
29 )
30 {
31     nativeFamily = NULL;
32     lastResult = DllExports::GdipCreateFontFamilyFromName(
33         name,
34         fontCollection ? fontCollection->nativeFontCollection : NULL,
35         &nativeFamily
36     );
37 
38 #ifndef DCR_USE_NEW_135429
39     if ((INT) lastResult >= 10)
40         lastResult = NotFound;
41 #endif
42 }
43 
44 // private method
45 inline
FontFamily(IN GpFontFamily * nativeOrig,IN Status status)46 FontFamily::FontFamily(
47     IN GpFontFamily *nativeOrig,
48     IN Status status
49 )
50 {
51     lastResult    = status;
52     nativeFamily = nativeOrig;
53 }
54 
55 // Generic font family access
56 
57 inline const FontFamily *
GenericSansSerif()58 FontFamily::GenericSansSerif()
59 {
60     if (GenericSansSerifFontFamily != NULL)
61     {
62         return GenericSansSerifFontFamily;
63     }
64 
65     GenericSansSerifFontFamily =
66         (FontFamily*) GenericSansSerifFontFamilyBuffer;
67 
68     GenericSansSerifFontFamily->lastResult =
69         DllExports::GdipGetGenericFontFamilySansSerif(
70             &(GenericSansSerifFontFamily->nativeFamily)
71         );
72 
73 #ifndef DCR_USE_NEW_135429
74     if ((INT) GenericSansSerifFontFamily->lastResult >= 10)
75         GenericSansSerifFontFamily->lastResult = NotFound;
76 #endif
77 
78     return GenericSansSerifFontFamily;
79 }
80 
81 inline const FontFamily *
GenericSerif()82 FontFamily::GenericSerif()
83 {
84     if (GenericSerifFontFamily != NULL)
85     {
86         return GenericSerifFontFamily;
87     }
88 
89     GenericSerifFontFamily =
90         (FontFamily*) GenericSerifFontFamilyBuffer;
91 
92     GenericSerifFontFamily->lastResult =
93         DllExports::GdipGetGenericFontFamilySerif(
94             &(GenericSerifFontFamily->nativeFamily)
95         );
96 
97 #ifndef DCR_USE_NEW_135429
98     if ((INT) GenericSerifFontFamily->lastResult >= 10)
99         GenericSerifFontFamily->lastResult = NotFound;
100 #endif
101 
102     return GenericSerifFontFamily;
103 }
104 
105 inline const FontFamily *
GenericMonospace()106 FontFamily::GenericMonospace()
107 {
108     if (GenericMonospaceFontFamily != NULL)
109     {
110         return GenericMonospaceFontFamily;
111     }
112 
113     GenericMonospaceFontFamily =
114         (FontFamily*) GenericMonospaceFontFamilyBuffer;
115 
116     GenericMonospaceFontFamily->lastResult =
117         DllExports::GdipGetGenericFontFamilyMonospace(
118             &(GenericMonospaceFontFamily->nativeFamily)
119         );
120 
121 #ifndef DCR_USE_NEW_135429
122     if ((INT) GenericMonospaceFontFamily->lastResult >= 10)
123         GenericMonospaceFontFamily->lastResult = NotFound;
124 #endif
125 
126     return GenericMonospaceFontFamily;
127 }
128 
~FontFamily()129 inline FontFamily::~FontFamily()
130 {
131     DllExports::GdipDeleteFontFamily (nativeFamily);
132 }
133 
134 inline FontFamily *
Clone()135 FontFamily::Clone() const
136 {
137     GpFontFamily * clonedFamily = NULL;
138 
139     SetStatus(DllExports::GdipCloneFontFamily (nativeFamily, &clonedFamily));
140 
141     return new FontFamily(clonedFamily, lastResult);
142 }
143 
144 inline Status
GetFamilyName(IN WCHAR name[LF_FACESIZE],IN LANGID language)145 FontFamily::GetFamilyName(
146     IN WCHAR name[LF_FACESIZE],
147     IN LANGID language
148 ) const
149 {
150     return SetStatus(DllExports::GdipGetFamilyName(nativeFamily,
151                                                    name,
152                                                    language));
153 }
154 
155 inline BOOL
IsStyleAvailable(IN INT style)156 FontFamily::IsStyleAvailable(IN INT style) const
157 {
158     BOOL    StyleAvailable;
159     Status  status;
160 
161     status = SetStatus(DllExports::GdipIsStyleAvailable(nativeFamily, style, &StyleAvailable));
162 
163     if (status != Ok)
164         StyleAvailable = FALSE;
165 
166     return StyleAvailable;
167 }
168 
169 
170 inline UINT16
GetEmHeight(IN INT style)171 FontFamily::GetEmHeight(IN INT style) const
172 {
173     UINT16  EmHeight;
174 
175     SetStatus(DllExports::GdipGetEmHeight(nativeFamily, style, &EmHeight));
176 
177     return EmHeight;
178 }
179 
180 inline UINT16
GetCellAscent(IN INT style)181 FontFamily::GetCellAscent(IN INT style) const
182 {
183     UINT16  CellAscent;
184 
185     SetStatus(DllExports::GdipGetCellAscent(nativeFamily, style, &CellAscent));
186 
187     return CellAscent;
188 }
189 
190 inline UINT16
GetCellDescent(IN INT style)191 FontFamily::GetCellDescent(IN INT style) const
192 {
193     UINT16  CellDescent;
194 
195     SetStatus(DllExports::GdipGetCellDescent(nativeFamily, style, &CellDescent));
196 
197     return CellDescent;
198 }
199 
200 
201 inline UINT16
GetLineSpacing(IN INT style)202 FontFamily::GetLineSpacing(IN INT style) const
203 {
204     UINT16  LineSpacing;
205 
206     SetStatus(DllExports::GdipGetLineSpacing(nativeFamily, style, &LineSpacing));
207 
208     return LineSpacing;
209 
210 }
211 
212 #ifdef TEXTV2
213 
214 // The following APIs return data from the font OS/2 table
215 
216 inline INT16
GetTypographicAscent(IN INT style)217 FontFamily::GetTypographicAscent(IN INT style) const
218 {
219     INT16  TypographicAscent;
220 
221     SetStatus(DllExports::GdipGetTypographicAscent(nativeFamily, style, &TypographicAscent));
222 
223     return TypographicAscent;
224 }
225 
226 inline INT16
GetTypographicDescent(IN INT style)227 FontFamily::GetTypographicDescent(IN INT style) const
228 {
229     INT16   TypographicDescent;
230 
231     SetStatus(DllExports::GdipGetTypographicDescent(nativeFamily, style, &TypographicDescent));
232 
233     return TypographicDescent;
234 }
235 
236 inline INT16
GetTypographicLineGap(IN INT style)237 FontFamily::GetTypographicLineGap(IN INT style) const
238 {
239     INT16   TypographicLineGap;
240 
241     SetStatus(DllExports::GdipGetTypographicLineGap(nativeFamily, style, &TypographicLineGap));
242 
243     return TypographicLineGap;
244 }
245 
246 #endif
247 
248 ///////////////////////////////////////////////////////////
249 
250 // GetLastStatus - return last error code and clear error code
251 
252 inline Status
GetLastStatus()253 FontFamily::GetLastStatus() const
254 {
255     Status lastStatus = lastResult;
256     lastResult = Ok;
257 
258     return lastStatus;
259 }
260 
261 // protected method
262 inline Status
SetStatus(Status status)263 FontFamily::SetStatus(Status status) const
264 {
265     if (status != Ok)
266         return (lastResult = status);
267     else
268         return status;
269 }
270 
271 #endif
272