4 * Copyright 2012 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "dwrite_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
30 struct dwrite_fontfamily
{
31 IDWriteFontFamily IDWriteFontFamily_iface
;
36 IDWriteFont IDWriteFont_iface
;
39 IDWriteFontFamily
*family
;
40 DWRITE_FONT_STYLE style
;
43 static inline struct dwrite_font
*impl_from_IDWriteFont(IDWriteFont
*iface
)
45 return CONTAINING_RECORD(iface
, struct dwrite_font
, IDWriteFont_iface
);
48 static inline struct dwrite_fontfamily
*impl_from_IDWriteFontFamily(IDWriteFontFamily
*iface
)
50 return CONTAINING_RECORD(iface
, struct dwrite_fontfamily
, IDWriteFontFamily_iface
);
53 static HRESULT WINAPI
dwritefont_QueryInterface(IDWriteFont
*iface
, REFIID riid
, void **obj
)
55 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
57 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
59 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteFont
))
62 IDWriteFont_AddRef(iface
);
70 static ULONG WINAPI
dwritefont_AddRef(IDWriteFont
*iface
)
72 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
73 ULONG ref
= InterlockedIncrement(&This
->ref
);
74 TRACE("(%p)->(%d)\n", This
, ref
);
78 static ULONG WINAPI
dwritefont_Release(IDWriteFont
*iface
)
80 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
81 ULONG ref
= InterlockedDecrement(&This
->ref
);
83 TRACE("(%p)->(%d)\n", This
, ref
);
87 IDWriteFontFamily_Release(This
->family
);
94 static HRESULT WINAPI
dwritefont_GetFontFamily(IDWriteFont
*iface
, IDWriteFontFamily
**family
)
96 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
97 TRACE("(%p)->(%p)\n", This
, family
);
99 *family
= This
->family
;
100 IDWriteFontFamily_AddRef(*family
);
104 static DWRITE_FONT_WEIGHT WINAPI
dwritefont_GetWeight(IDWriteFont
*iface
)
106 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
107 FIXME("(%p): stub\n", This
);
111 static DWRITE_FONT_STRETCH WINAPI
dwritefont_GetStretch(IDWriteFont
*iface
)
113 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
114 FIXME("(%p): stub\n", This
);
115 return DWRITE_FONT_STRETCH_UNDEFINED
;
118 static DWRITE_FONT_STYLE WINAPI
dwritefont_GetStyle(IDWriteFont
*iface
)
120 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
121 TRACE("(%p)\n", This
);
125 static BOOL WINAPI
dwritefont_IsSymbolFont(IDWriteFont
*iface
)
127 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
128 FIXME("(%p): stub\n", This
);
132 static HRESULT WINAPI
dwritefont_GetFaceNames(IDWriteFont
*iface
, IDWriteLocalizedStrings
**names
)
134 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
135 FIXME("(%p)->(%p): stub\n", This
, names
);
139 static HRESULT WINAPI
dwritefont_GetInformationalStrings(IDWriteFont
*iface
,
140 DWRITE_INFORMATIONAL_STRING_ID stringid
, IDWriteLocalizedStrings
**strings
, BOOL
*exists
)
142 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
143 FIXME("(%p)->(%d %p %p): stub\n", This
, stringid
, strings
, exists
);
147 static DWRITE_FONT_SIMULATIONS WINAPI
dwritefont_GetSimulations(IDWriteFont
*iface
)
149 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
150 FIXME("(%p): stub\n", This
);
151 return DWRITE_FONT_SIMULATIONS_NONE
;
154 static void WINAPI
dwritefont_GetMetrics(IDWriteFont
*iface
, DWRITE_FONT_METRICS
*metrics
)
156 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
157 FIXME("(%p)->(%p): stub\n", This
, metrics
);
160 static HRESULT WINAPI
dwritefont_HasCharacter(IDWriteFont
*iface
, UINT32 value
, BOOL
*exists
)
162 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
163 FIXME("(%p)->(0x%08x %p): stub\n", This
, value
, exists
);
167 static HRESULT WINAPI
dwritefont_CreateFontFace(IDWriteFont
*iface
, IDWriteFontFace
**face
)
169 struct dwrite_font
*This
= impl_from_IDWriteFont(iface
);
170 FIXME("(%p)->(%p): stub\n", This
, face
);
174 static const IDWriteFontVtbl dwritefontvtbl
= {
175 dwritefont_QueryInterface
,
178 dwritefont_GetFontFamily
,
179 dwritefont_GetWeight
,
180 dwritefont_GetStretch
,
182 dwritefont_IsSymbolFont
,
183 dwritefont_GetFaceNames
,
184 dwritefont_GetInformationalStrings
,
185 dwritefont_GetSimulations
,
186 dwritefont_GetMetrics
,
187 dwritefont_HasCharacter
,
188 dwritefont_CreateFontFace
191 static HRESULT WINAPI
dwritefontfamily_QueryInterface(IDWriteFontFamily
*iface
, REFIID riid
, void **obj
)
193 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
194 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
196 if (IsEqualIID(riid
, &IID_IUnknown
) ||
197 IsEqualIID(riid
, &IID_IDWriteFontList
) ||
198 IsEqualIID(riid
, &IID_IDWriteFontFamily
))
201 IDWriteFontFamily_AddRef(iface
);
206 return E_NOINTERFACE
;
209 static ULONG WINAPI
dwritefontfamily_AddRef(IDWriteFontFamily
*iface
)
211 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
212 ULONG ref
= InterlockedIncrement(&This
->ref
);
213 TRACE("(%p)->(%d)\n", This
, ref
);
217 static ULONG WINAPI
dwritefontfamily_Release(IDWriteFontFamily
*iface
)
219 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
220 ULONG ref
= InterlockedDecrement(&This
->ref
);
222 TRACE("(%p)->(%d)\n", This
, ref
);
230 static HRESULT WINAPI
dwritefontfamily_GetFontCollection(IDWriteFontFamily
*iface
, IDWriteFontCollection
**collection
)
232 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
233 FIXME("(%p)->(%p): stub\n", This
, collection
);
237 static UINT32 WINAPI
dwritefontfamily_GetFontCount(IDWriteFontFamily
*iface
)
239 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
240 FIXME("(%p): stub\n", This
);
244 static HRESULT WINAPI
dwritefontfamily_GetFont(IDWriteFontFamily
*iface
, UINT32 index
, IDWriteFont
**font
)
246 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
247 FIXME("(%p)->(%u %p): stub\n", This
, index
, font
);
251 static HRESULT WINAPI
dwritefontfamily_GetFamilyNames(IDWriteFontFamily
*iface
, IDWriteLocalizedStrings
**names
)
253 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
254 FIXME("(%p)->(%p): stub\n", This
, names
);
258 static HRESULT WINAPI
dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily
*iface
, DWRITE_FONT_WEIGHT weight
,
259 DWRITE_FONT_STRETCH stretch
, DWRITE_FONT_STYLE style
, IDWriteFont
**font
)
261 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
262 FIXME("(%p)->(%d %d %d %p): stub\n", This
, weight
, stretch
, style
, font
);
266 static HRESULT WINAPI
dwritefontfamily_GetMatchingFonts(IDWriteFontFamily
*iface
, DWRITE_FONT_WEIGHT weight
,
267 DWRITE_FONT_STRETCH stretch
, DWRITE_FONT_STYLE style
, IDWriteFontList
**fonts
)
269 struct dwrite_fontfamily
*This
= impl_from_IDWriteFontFamily(iface
);
270 FIXME("(%p)->(%d %d %d %p): stub\n", This
, weight
, stretch
, style
, fonts
);
274 static const IDWriteFontFamilyVtbl fontfamilyvtbl
= {
275 dwritefontfamily_QueryInterface
,
276 dwritefontfamily_AddRef
,
277 dwritefontfamily_Release
,
278 dwritefontfamily_GetFontCollection
,
279 dwritefontfamily_GetFontCount
,
280 dwritefontfamily_GetFont
,
281 dwritefontfamily_GetFamilyNames
,
282 dwritefontfamily_GetFirstMatchingFont
,
283 dwritefontfamily_GetMatchingFonts
286 static HRESULT
create_fontfamily(IDWriteFontFamily
**family
)
288 struct dwrite_fontfamily
*This
;
292 This
= heap_alloc(sizeof(struct dwrite_fontfamily
));
293 if (!This
) return E_OUTOFMEMORY
;
295 This
->IDWriteFontFamily_iface
.lpVtbl
= &fontfamilyvtbl
;
298 *family
= &This
->IDWriteFontFamily_iface
;
303 HRESULT
create_font_from_logfont(const LOGFONTW
*logfont
, IDWriteFont
**font
)
305 struct dwrite_font
*This
;
306 IDWriteFontFamily
*family
;
311 hr
= create_fontfamily(&family
);
312 if (hr
!= S_OK
) return hr
;
314 This
= heap_alloc(sizeof(struct dwrite_font
));
317 IDWriteFontFamily_Release(family
);
318 return E_OUTOFMEMORY
;
321 This
->IDWriteFont_iface
.lpVtbl
= &dwritefontvtbl
;
323 This
->family
= family
;
324 This
->style
= logfont
->lfItalic
? DWRITE_FONT_STYLE_ITALIC
: DWRITE_FONT_STYLE_NORMAL
;
326 *font
= &This
->IDWriteFont_iface
;