From f6ea5c8a0f94c03d88376e69db31ead707ae4028 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Wed, 22 May 2013 19:46:28 +0900 Subject: [PATCH] gdi32: Add a helper to get the default character index. --- dlls/gdi32/freetype.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index bc437721be7..50bd52bd227 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -5817,6 +5817,25 @@ static FT_UInt get_glyph_index(const GdiFont *font, UINT glyph) return glyphId; } +static FT_UInt get_default_char_index(GdiFont *font) +{ + FT_UInt default_char; + + if (FT_IS_SFNT(font->ft_face)) + { + TT_OS2 *pOS2 = pFT_Get_Sfnt_Table(font->ft_face, ft_sfnt_os2); + default_char = (pOS2->usDefaultChar ? get_glyph_index(font, pOS2->usDefaultChar) : 0); + } + else + { + TEXTMETRICW textm; + get_text_metrics(font, &textm); + default_char = textm.tmDefaultChar; + } + + return default_char; +} + /************************************************************* * freetype_GetGlyphIndices */ @@ -5849,17 +5868,7 @@ static DWORD freetype_GetGlyphIndices( PHYSDEV dev, LPCWSTR lpstr, INT count, LP { if (!got_default) { - if (FT_IS_SFNT(physdev->font->ft_face)) - { - TT_OS2 *pOS2 = pFT_Get_Sfnt_Table(physdev->font->ft_face, ft_sfnt_os2); - default_char = (pOS2->usDefaultChar ? get_glyph_index(physdev->font, pOS2->usDefaultChar) : 0); - } - else - { - TEXTMETRICW textm; - get_text_metrics(physdev->font, &textm); - default_char = textm.tmDefaultChar; - } + default_char = get_default_char_index(physdev->font); got_default = TRUE; } pgi[i] = default_char;