Module: wine Branch: master Commit: cf3e92994d286e287cd9effa63ee1d99ccdab44d URL: http://source.winehq.org/git/wine.git/?a=commit;h=cf3e92994d286e287cd9effa63...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Mar 8 22:46:52 2016 +0300
dwrite: Implement IDWriteFontFamily1::GetFont().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dwrite/font.c | 24 ++++++++++++++++-------- dlls/dwrite/tests/font.c | 6 +----- 2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 76321bb..edfde6f 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -1541,7 +1541,7 @@ static const IDWriteFont3Vtbl dwritefontvtbl = { dwritefont3_GetLocality };
-static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily1 *family, IDWriteFont **font) +static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily1 *family, IDWriteFont3 **font) { struct dwrite_font *This; *font = NULL; @@ -1557,7 +1557,7 @@ static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily1 *fa This->data = data; InterlockedIncrement(&This->data->ref);
- *font = (IDWriteFont*)&This->IDWriteFont3_iface; + *font = &This->IDWriteFont3_iface;
return S_OK; } @@ -1635,7 +1635,7 @@ static HRESULT WINAPI dwritefontlist_GetFont(IDWriteFontList *iface, UINT32 inde if (index >= This->font_count) return E_INVALIDARG;
- return create_font(This->fonts[index], This->family, font); + return create_font(This->fonts[index], This->family, (IDWriteFont3**)font); }
static const IDWriteFontListVtbl dwritefontlistvtbl = { @@ -1723,7 +1723,7 @@ static HRESULT WINAPI dwritefontfamily_GetFont(IDWriteFontFamily1 *iface, UINT32 if (index >= This->data->font_count) return E_INVALIDARG;
- return create_font(This->data->fonts[index], iface, font); + return create_font(This->data->fonts[index], iface, (IDWriteFont3**)font); }
static HRESULT WINAPI dwritefontfamily_GetFamilyNames(IDWriteFontFamily1 *iface, IDWriteLocalizedStrings **names) @@ -1796,7 +1796,7 @@ static HRESULT WINAPI dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily1 * match = This->data->fonts[i]; }
- return create_font(match, iface, font); + return create_font(match, iface, (IDWriteFont3**)font); }
typedef BOOL (*matching_filter_func)(const struct dwrite_font_data*); @@ -1902,9 +1902,17 @@ static HRESULT WINAPI dwritefontfamily1_GetFont(IDWriteFontFamily1 *iface, UINT3 { struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily1(iface);
- FIXME("(%p)->(%u %p): stub\n", This, index, font); + TRACE("(%p)->(%u %p)\n", This, index, font);
- return E_NOTIMPL; + *font = NULL; + + if (This->data->font_count == 0) + return S_FALSE; + + if (index >= This->data->font_count) + return E_FAIL; + + return create_font(This->data->fonts[index], iface, font); }
static HRESULT WINAPI dwritefontfamily1_GetFontFaceReference(IDWriteFontFamily1 *iface, UINT32 index, @@ -2121,7 +2129,7 @@ static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollec if (FAILED(hr)) return hr;
- hr = create_font(found_font, family, font); + hr = create_font(found_font, family, (IDWriteFont3**)font); IDWriteFontFamily1_Release(family); return hr; } diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index a2c1ce0..8982f19 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -1128,15 +1128,12 @@ if (0) /* crashes on native */
font3 = (void*)0xdeadbeef; hr = IDWriteFontFamily1_GetFont(family1, ~0u, &font3); - todo_wine { ok(hr == E_FAIL, "got 0x%08x\n", hr); ok(font3 == NULL, "got %p\n", font3); - } + hr = IDWriteFontFamily1_GetFont(family1, 0, &font3); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- if (hr == S_OK) { hr = IDWriteFont3_QueryInterface(font3, &IID_IDWriteFont, (void**)&font); ok(hr == S_OK, "got 0x%08x\n", hr); IDWriteFont_Release(font); @@ -1146,7 +1143,6 @@ if (0) /* crashes on native */ IDWriteFont1_Release(font1);
IDWriteFont3_Release(font3); - } IDWriteFontFamily1_Release(family1); } else