Module: wine Branch: master Commit: 9b46e19aa43f4cab48329438051206e1013f961c URL: http://source.winehq.org/git/wine.git/?a=commit;h=9b46e19aa43f4cab4832943805...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Thu Oct 16 07:30:40 2014 +0400
dwrite: Implement HasCharacter().
---
dlls/dwrite/font.c | 22 ++++++++++++++++++++-- dlls/dwrite/tests/font.c | 11 +++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index a220501..69b7746 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -835,8 +835,26 @@ static void WINAPI dwritefont_GetMetrics(IDWriteFont2 *iface, DWRITE_FONT_METRIC static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont2 *iface, UINT32 value, BOOL *exists) { struct dwrite_font *This = impl_from_IDWriteFont2(iface); - FIXME("(%p)->(0x%08x %p): stub\n", This, value, exists); - return E_NOTIMPL; + IDWriteFontFace *fontface; + UINT16 index; + HRESULT hr; + + TRACE("(%p)->(0x%08x %p)\n", This, value, exists); + + *exists = FALSE; + + hr = IDWriteFont2_CreateFontFace(iface, &fontface); + if (FAILED(hr)) + return hr; + + index = 0; + hr = IDWriteFontFace_GetGlyphIndices(fontface, &value, 1, &index); + IDWriteFontFace_Release(fontface); + if (FAILED(hr)) + return hr; + + *exists = index != 0; + return S_OK; }
static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont2 *iface, IDWriteFontFace **face) diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 33c47bd..5e269c3 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -218,6 +218,7 @@ static void test_CreateFontFromLOGFONT(void) BOOL ret; HDC hdc; HFONT hfont; + BOOL exists; int i; UINT r;
@@ -251,6 +252,16 @@ if (0) DeleteDC(hdc); DeleteObject(hfont);
+ exists = TRUE; + hr = IDWriteFont_HasCharacter(font, 0xd800, &exists); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(exists == FALSE, "got %d\n", exists); + + exists = FALSE; + hr = IDWriteFont_HasCharacter(font, 0x20, &exists); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(exists == TRUE, "got %d\n", exists); + /* now check properties */ weight = IDWriteFont_GetWeight(font); ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight);