From e94d977006985536135fa0c4ce63a756e536e16f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 15 Jul 2015 14:40:32 +0300 Subject: [PATCH] dwrite: Partially implement GetGdiCompatibleGlyphAdvances(). --- dlls/dwrite/dwrite_private.h | 7 +++++++ dlls/dwrite/font.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index a102e1426a1..0111e46af2c 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -92,6 +92,13 @@ static inline const char *debugstr_range(const DWRITE_TEXT_RANGE *range) return wine_dbg_sprintf("%u:%u", range->startPosition, range->length); } +static inline const char *debugstr_matrix(const DWRITE_MATRIX *m) +{ + if (!m) return "(null)"; + return wine_dbg_sprintf("{%.2f,%.2f,%.2f,%.2f,%.2f,%.2f}", m->m11, m->m12, m->m21, m->m22, + m->dx, m->dy); +} + static inline unsigned short get_table_entry(const unsigned short *table, WCHAR ch) { return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)]; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 41b02508a0f..9b7a50fce85 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -619,7 +619,7 @@ static void WINAPI dwritefontface1_GetMetrics(IDWriteFontFace2 *iface, DWRITE_FO static inline int round_metric(FLOAT metric) { - return (int)floor(metric + 0.5); + return (int)floorf(metric + 0.5f); } static HRESULT WINAPI dwritefontface1_GetGdiCompatibleMetrics(IDWriteFontFace2 *iface, FLOAT em_size, FLOAT pixels_per_dip, @@ -729,13 +729,33 @@ static HRESULT WINAPI dwritefontface1_GetDesignGlyphAdvances(IDWriteFontFace2 *i } static HRESULT WINAPI dwritefontface1_GetGdiCompatibleGlyphAdvances(IDWriteFontFace2 *iface, - FLOAT em_size, FLOAT pixels_per_dip, const DWRITE_MATRIX *transform, BOOL use_gdi_natural, - BOOL is_sideways, UINT32 glyph_count, UINT16 const *indices, INT32 *advances) + FLOAT em_size, FLOAT ppdip, const DWRITE_MATRIX *m, BOOL use_gdi_natural, + BOOL is_sideways, UINT32 glyph_count, UINT16 const *glyphs, INT32 *advances) { struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface); - FIXME("(%p)->(%f %f %p %d %d %u %p %p): stub\n", This, em_size, pixels_per_dip, transform, - use_gdi_natural, is_sideways, glyph_count, indices, advances); - return E_NOTIMPL; + HRESULT hr; + UINT32 i; + + TRACE("(%p)->(%.2f %.2f %p %d %d %u %p %p)\n", This, em_size, ppdip, m, + use_gdi_natural, is_sideways, glyph_count, glyphs, advances); + + if (m && memcmp(m, &identity, sizeof(*m))) + FIXME("transform is not supported, %s\n", debugstr_matrix(m)); + + for (i = 0; i < glyph_count; i++) { + FLOAT scale; + + hr = IDWriteFontFace2_GetDesignGlyphAdvances(iface, 1, glyphs + i, advances + i, is_sideways); + if (FAILED(hr)) + return hr; + + scale = em_size * ppdip / This->metrics.designUnitsPerEm; +#define SCALE_METRIC(x) x = round_metric(round_metric((x) * scale) / scale) + SCALE_METRIC(advances[i]); +#undef SCALE_METRIC + } + + return S_OK; } static HRESULT WINAPI dwritefontface1_GetKerningPairAdjustments(IDWriteFontFace2 *iface, UINT32 count, -- 2.11.4.GIT