From 2bcecaeb47d3daa802054b4deb59afc74148af52 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Thu, 26 Oct 2017 14:31:44 +0900 Subject: [PATCH] fix Anastasia font issue --- win32ss/gdi/ntgdi/freetype.c | 82 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index eb2fc7756d..06efd66eb6 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -1496,8 +1496,11 @@ static BOOL face_has_symbol_charmap(FT_Face ft_face) for(i = 0; i < ft_face->num_charmaps; i++) { - if(ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL) + if (ft_face->charmaps[i]->platform_id == TT_PLATFORM_MICROSOFT && + ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL) + { return TRUE; + } } return FALSE; } @@ -3081,6 +3084,28 @@ TextIntUpdateSize(PDC dc, return TRUE; } +static FT_UInt +IntGetGlyphIndex(FT_Face face, FT_ULong code, DWORD indexed_flag, DWORD flags) +{ + FT_UInt glyph_index; + if (flags & indexed_flag) + { + glyph_index = code; + } + else + { + glyph_index = FT_Get_Char_Index(face, code); + if (glyph_index == 0 && 0x20 <= code && code < 0x100) + { + if (face_has_symbol_charmap(face)) + { + /* use M$ symbol area */ + glyph_index = FT_Get_Char_Index(face, code | 0xF000); + } + } + } + return glyph_index; +} /* * Based on WineEngGetGlyphOutline @@ -3169,12 +3194,8 @@ ftGdiGetGlyphOutline( TEXTOBJ_UnlockText(TextObj); - if (iFormat & GGO_GLYPH_INDEX) - { - glyph_index = wch; - iFormat &= ~GGO_GLYPH_INDEX; - } - else glyph_index = FT_Get_Char_Index(ft_face, wch); + glyph_index = IntGetGlyphIndex(ft_face, wch, GGO_GLYPH_INDEX, iFormat); + iFormat &= ~GGO_GLYPH_INDEX; if (orientation || (iFormat != GGO_METRICS && iFormat != GGO_BITMAP) || aveWidth || pmat2) load_flags |= FT_LOAD_NO_BITMAP; @@ -3603,10 +3624,7 @@ TextIntGetTextExtentPoint(PDC dc, for (i = 0; i < Count; i++) { - if (fl & GTEF_INDICES) - glyph_index = *String; - else - glyph_index = FT_Get_Char_Index(face, *String); + glyph_index = IntGetGlyphIndex(face, *String, GTEF_INDICES, fl); if (EmuBold || EmuItalic) realglyph = NULL; @@ -5315,10 +5333,8 @@ GreExtTextOutW( for (i = iStart; i < Count; i++) { - if (fuOptions & ETO_GLYPH_INDEX) - glyph_index = *TempText; - else - glyph_index = FT_Get_Char_Index(face, *TempText); + glyph_index = IntGetGlyphIndex(face, *TempText, ETO_GLYPH_INDEX, + fuOptions); if (EmuBold || EmuItalic) realglyph = NULL; @@ -5420,10 +5436,8 @@ GreExtTextOutW( BackgroundLeft = (RealXStart + 32) >> 6; for (i = 0; i < Count; ++i) { - if (fuOptions & ETO_GLYPH_INDEX) - glyph_index = String[i]; - else - glyph_index = FT_Get_Char_Index(face, String[i]); + glyph_index = IntGetGlyphIndex(face, String[i], ETO_GLYPH_INDEX, + fuOptions); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); if (error) @@ -5538,10 +5552,8 @@ GreExtTextOutW( BackgroundLeft = (RealXStart + 32) >> 6; for (i = 0; i < Count; ++i) { - if (fuOptions & ETO_GLYPH_INDEX) - glyph_index = String[i]; - else - glyph_index = FT_Get_Char_Index(face, String[i]); + glyph_index = IntGetGlyphIndex(face, String[i], ETO_GLYPH_INDEX, + fuOptions); if (EmuBold || EmuItalic) realglyph = NULL; @@ -6083,17 +6095,12 @@ NtGdiGetCharABCWidthsW( if (Safepwch) { - if (fl & GCABCW_INDICES) - glyph_index = Safepwch[i - FirstChar]; - else - glyph_index = FT_Get_Char_Index(face, Safepwch[i - FirstChar]); + glyph_index = IntGetGlyphIndex(face, Safepwch[i - FirstChar], + GCABCW_INDICES, fl); } else { - if (fl & GCABCW_INDICES) - glyph_index = i; - else - glyph_index = FT_Get_Char_Index(face, i); + glyph_index = IntGetGlyphIndex(face, i, GCABCW_INDICES, fl); } FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); @@ -6277,17 +6284,12 @@ NtGdiGetCharWidthW( { if (Safepwc) { - if (fl & GCW_INDICES) - glyph_index = Safepwc[i - FirstChar]; - else - glyph_index = FT_Get_Char_Index(face, Safepwc[i - FirstChar]); + glyph_index = IntGetGlyphIndex(face, Safepwc[i - FirstChar], + GCW_INDICES, fl); } else { - if (fl & GCW_INDICES) - glyph_index = i; - else - glyph_index = FT_Get_Char_Index(face, i); + glyph_index = IntGetGlyphIndex(face, i, GCW_INDICES, fl); } FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); if (!fl) @@ -6443,7 +6445,7 @@ NtGdiGetGlyphIndicesW( for (i = 0; i < cwc; i++) { - Buffer[i] = FT_Get_Char_Index(FontGDI->SharedFace->Face, Safepwc[i]); + Buffer[i] = IntGetGlyphIndex(FontGDI->SharedFace->Face, Safepwc[i], 0, 0); if (Buffer[i] == 0) { Buffer[i] = DefChar; -- 2.14.2