Module: wine Branch: master Commit: 415e0b3f54968017014060a0cddab6f639f63def URL: http://source.winehq.org/git/wine.git/?a=commit;h=415e0b3f54968017014060a0cd...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Dec 9 10:00:45 2014 +0300
dwrite: Implement GetDesignGlyphAdvances().
---
dlls/dwrite/font.c | 20 +++++++++++++++--- dlls/dwrite/tests/font.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index ef4c32c..ebea17d 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -500,11 +500,25 @@ static BOOL WINAPI dwritefontface1_IsMonospacedFont(IDWriteFontFace2 *iface) }
static HRESULT WINAPI dwritefontface1_GetDesignGlyphAdvances(IDWriteFontFace2 *iface, - UINT32 glyph_count, UINT16 const *indices, INT32 *advances, BOOL is_sideways) + UINT32 glyph_count, UINT16 const *glyphs, INT32 *advances, BOOL is_sideways) { struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface); - FIXME("(%p)->(%u %p %p %d): stub\n", This, glyph_count, indices, advances, is_sideways); - return E_NOTIMPL; + UINT32 i; + + TRACE("(%p)->(%u %p %p %d)\n", This, glyph_count, glyphs, advances, is_sideways); + + for (i = 0; i < glyph_count; i++) { + DWRITE_GLYPH_METRICS metrics = { 0 }; + HRESULT hr; + + hr = IDWriteFontFace2_GetDesignGlyphMetrics(iface, glyphs + i, 1, &metrics, is_sideways); + if (FAILED(hr)) + return hr; + + advances[i] = is_sideways ? metrics.advanceHeight : metrics.advanceWidth; + } + + return S_OK; }
static HRESULT WINAPI dwritefontface1_GetGdiCompatibleGlyphAdvances(IDWriteFontFace2 *iface, diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index db554eb..b8bf75c 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -2636,6 +2636,58 @@ static void test_IsMonospacedFont(void) IDWriteFontCollection_Release(collection); }
+static void test_GetDesignGlyphAdvances(void) +{ + IDWriteFontFace1 *fontface1; + IDWriteFontFace *fontface; + IDWriteFactory *factory; + IDWriteFontFile *file; + HRESULT hr; + + factory = create_factory(); + + create_testfontfile(test_fontfile); + + hr = IDWriteFactory_CreateFontFileReference(factory, test_fontfile, NULL, &file); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, + 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface); + ok(hr == S_OK, "got 0x%08x\n", hr); + IDWriteFontFile_Release(file); + + hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1); + if (hr == S_OK) { + UINT32 codepoint; + UINT16 index; + INT32 advance; + + codepoint = 'A'; + index = 0; + hr = IDWriteFontFace1_GetGlyphIndices(fontface1, &codepoint, 1, &index); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(index > 0, "got %u\n", index); + + advance = 0; + hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &index, &advance, FALSE); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(advance == 1000, "got %i\n", advance); + + advance = 0; + hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &index, &advance, TRUE); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(advance == 2048, "got %i\n", advance); + + IDWriteFontFace1_Release(fontface1); + } + else + win_skip("GetDesignGlyphAdvances() is not supported.\n"); + + IDWriteFontFace_Release(fontface); + IDWriteFactory_Release(factory); + DeleteFileW(test_fontfile); +} + START_TEST(font) { IDWriteFactory *factory; @@ -2670,6 +2722,7 @@ START_TEST(font) test_CreateStreamFromKey(); test_ReadFileFragment(); test_GetDesignGlyphMetrics(); + test_GetDesignGlyphAdvances(); test_IsMonospacedFont();
IDWriteFactory_Release(factory);