dwrite: Implement GetDesignGlyphAdvances().
This commit is contained in:
parent
730b2f4c66
commit
415e0b3f54
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue