Alexandre Julliard : gdi32: Move the GetGlyphIndices() implementation out of freetype.c.
Alexandre Julliard
julliard at winehq.org
Thu Oct 22 15:27:31 CDT 2020
Module: wine
Branch: master
Commit: 5bdc6e0fe64222d8d7d383616f5e230928af011a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5bdc6e0fe64222d8d7d383616f5e230928af011a
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Oct 22 13:13:52 2020 +0200
gdi32: Move the GetGlyphIndices() implementation out of freetype.c.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/font.c | 44 +++++++++++++++++++--
dlls/gdi32/freetype.c | 100 ++++++++++++++++-------------------------------
dlls/gdi32/gdi_private.h | 3 +-
3 files changed, 76 insertions(+), 71 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 8c85614cb49..9c4fec88e1a 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -1103,17 +1103,55 @@ static DWORD CDECL font_GetFontUnicodeRanges( PHYSDEV dev, GLYPHSET *glyphset )
static DWORD CDECL font_GetGlyphIndices( PHYSDEV dev, const WCHAR *str, INT count, WORD *gi, DWORD flags )
{
struct font_physdev *physdev = get_font_dev( dev );
- DWORD ret;
+ UINT default_char;
+ char ch;
+ BOOL used, got_default = FALSE;
+ int i;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetGlyphIndices );
return dev->funcs->pGetGlyphIndices( dev, str, count, gi, flags );
}
+
+ if (flags & GGI_MARK_NONEXISTING_GLYPHS)
+ {
+ default_char = 0xffff; /* XP would use 0x1f for bitmap fonts */
+ got_default = TRUE;
+ }
+
EnterCriticalSection( &font_cs );
- ret = font_funcs->pGetGlyphIndices( physdev->font, str, count, gi, flags );
+
+ for (i = 0; i < count; i++)
+ {
+ UINT glyph = str[i];
+
+ if (!font_funcs->get_glyph_index( physdev->font, &glyph ))
+ {
+ glyph = 0;
+ if (physdev->font->codepage == CP_SYMBOL)
+ {
+ if (str[i] >= 0xf020 && str[i] <= 0xf100) glyph = str[i] - 0xf000;
+ else if (str[i] < 0x100) glyph = str[i];
+ }
+ else if (WideCharToMultiByte( physdev->font->codepage, 0, &str[i], 1,
+ &ch, 1, NULL, &used ) && !used)
+ glyph = (unsigned char)ch;
+ }
+ if (!glyph)
+ {
+ if (!got_default)
+ {
+ default_char = font_funcs->get_default_glyph( physdev->font );
+ got_default = TRUE;
+ }
+ glyph = default_char;
+ }
+ gi[i] = glyph;
+ }
+
LeaveCriticalSection( &font_cs );
- return ret;
+ return count;
}
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index b06a26b9e34..718c7f3407e 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -5661,89 +5661,54 @@ static FT_UInt get_glyph_index(const GdiFont *font, UINT glyph)
return pFT_Get_Char_Index(font->ft_face, glyph);
}
-/* helper for freetype_GetGlyphIndices */
-static FT_UInt get_gdi_glyph_index(const GdiFont *font, UINT glyph)
+/*************************************************************
+ * freetype_get_glyph_index
+ */
+static BOOL CDECL freetype_get_glyph_index( struct gdi_font *gdi_font, UINT *glyph )
{
- struct gdi_font *gdi_font = font->gdi_font;
- WCHAR wc = (WCHAR)glyph;
- BOOL default_used = FALSE;
- BOOL *default_used_pointer = NULL;
- FT_UInt ret;
- char buf;
+ GdiFont *font = get_font_ptr( gdi_font );
- if(font->ft_face->charmap->encoding != FT_ENCODING_NONE)
- return get_glyph_index(font, glyph);
+ if (font->ft_face->charmap->encoding == FT_ENCODING_NONE) return FALSE;
- if (codepage_sets_default_used(gdi_font->codepage))
- default_used_pointer = &default_used;
- if(!WideCharToMultiByte(gdi_font->codepage, 0, &wc, 1, &buf, sizeof(buf), NULL, default_used_pointer)
- || default_used)
+ if (font->ft_face->charmap->encoding == FT_ENCODING_MS_SYMBOL)
{
- if (gdi_font->codepage == CP_SYMBOL && wc < 0x100)
- ret = (unsigned char)wc;
- else
- ret = 0;
- }
- else
- ret = (unsigned char)buf;
- TRACE("%04x (%02x) -> ret %d def_used %d\n", glyph, (unsigned char)buf, ret, default_used);
- return ret;
-}
-
-static FT_UInt get_default_char_index(GdiFont *font)
-{
- FT_UInt default_char;
+ if (!(*glyph = get_glyph_index_symbol( font, *glyph )))
+ {
+ WCHAR wc = *glyph;
+ char ch;
- 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;
+ if (WideCharToMultiByte( CP_ACP, 0, &wc, 1, &ch, 1, NULL, NULL ))
+ *glyph = get_glyph_index_symbol( font, (unsigned char)ch );
+ }
+ return TRUE;
}
- return default_char;
+ if ((*glyph = pFT_Get_Char_Index( font->ft_face, *glyph )))
+ *glyph = get_GSUB_vert_glyph( font, *glyph );
+
+ return TRUE;
}
/*************************************************************
- * freetype_GetGlyphIndices
+ * freetype_get_default_glyph
*/
-static DWORD CDECL freetype_GetGlyphIndices( struct gdi_font *gdi_font, LPCWSTR lpstr,
- INT count, LPWORD pgi, DWORD flags )
+static UINT CDECL freetype_get_default_glyph( struct gdi_font *gdi_font )
{
- GdiFont *font = get_font_ptr(gdi_font);
- int i;
- WORD default_char;
- BOOL got_default = FALSE;
-
- if (flags & GGI_MARK_NONEXISTING_GLYPHS)
- {
- default_char = 0xffff; /* XP would use 0x1f for bitmap fonts */
- got_default = TRUE;
- }
+ GdiFont *font = get_font_ptr( gdi_font );
+ FT_WinFNT_HeaderRec winfnt;
+ TT_OS2 *pOS2;
- for(i = 0; i < count; i++)
+ if ((pOS2 = pFT_Get_Sfnt_Table( font->ft_face, ft_sfnt_os2 )))
{
- pgi[i] = get_gdi_glyph_index(font, lpstr[i]);
- if (pgi[i] == 0)
- {
- if (!got_default)
- {
- default_char = get_default_char_index(font);
- got_default = TRUE;
- }
- pgi[i] = default_char;
- }
- else
- pgi[i] = get_GSUB_vert_glyph(font, pgi[i]);
+ UINT glyph = pOS2->usDefaultChar;
+ freetype_get_glyph_index( gdi_font, &glyph );
+ return glyph;
}
- return count;
+ if (!pFT_Get_WinFNT_Header( font->ft_face, &winfnt )) return winfnt.default_char + winfnt.first_char;
+ return 32;
}
+
static inline BOOL is_identity_FMAT2(const FMAT2 *matrix)
{
static const FMAT2 identity = { 1.0, 0.0, 0.0, 1.0 };
@@ -7838,7 +7803,6 @@ static const struct font_backend_funcs font_funcs =
freetype_FontIsLinked,
freetype_GetCharWidthInfo,
freetype_GetFontUnicodeRanges,
- freetype_GetGlyphIndices,
freetype_GetKerningPairs,
freetype_GetOutlineTextMetrics,
freetype_GetTextMetrics,
@@ -7849,6 +7813,8 @@ static const struct font_backend_funcs font_funcs =
freetype_CreateScalableFontResource,
freetype_alloc_font,
freetype_get_font_data,
+ freetype_get_glyph_index,
+ freetype_get_default_glyph,
freetype_get_glyph_outline,
freetype_destroy_font
};
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 2302dc5a7a7..6d1caf6c65e 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -356,7 +356,6 @@ struct font_backend_funcs
BOOL (CDECL *pFontIsLinked)( struct gdi_font *font );
BOOL (CDECL *pGetCharWidthInfo)( struct gdi_font *font, struct char_width_info *info );
DWORD (CDECL *pGetFontUnicodeRanges)( struct gdi_font *font, GLYPHSET *glyphset );
- DWORD (CDECL *pGetGlyphIndices)( struct gdi_font *font, const WCHAR *str, INT count, WORD *gi, DWORD flags );
DWORD (CDECL *pGetKerningPairs)( struct gdi_font *font, DWORD count, KERNINGPAIR *pairs );
UINT (CDECL *pGetOutlineTextMetrics)( struct gdi_font *font, UINT size, OUTLINETEXTMETRICW *metrics );
BOOL (CDECL *pGetTextMetrics)( struct gdi_font *font, TEXTMETRICW *metrics );
@@ -371,6 +370,8 @@ struct font_backend_funcs
BOOL (CDECL *alloc_font)( struct gdi_font *font );
DWORD (CDECL *get_font_data)( struct gdi_font *gdi_font, DWORD table, DWORD offset,
void *buf, DWORD count );
+ BOOL (CDECL *get_glyph_index)( struct gdi_font *gdi_font, UINT *glyph );
+ UINT (CDECL *get_default_glyph)( struct gdi_font *gdi_font );
DWORD (CDECL *get_glyph_outline)( struct gdi_font *font, UINT glyph, UINT format,
GLYPHMETRICS *gm, ABC *abc, DWORD buflen, void *buf, const MAT2 *mat );
void (CDECL *destroy_font)( struct gdi_font *font );
More information about the wine-cvs
mailing list