[vlc-commits] freetype: fix GDI font charset deduplication

Francois Cartegnie git at videolan.org
Mon Aug 24 17:39:41 CEST 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Aug 21 13:36:37 2020 +0200| [cc573ea9039ac3aeb556c7a0f736f0c2d89b171f] | committer: Francois Cartegnie

freetype: fix GDI font charset deduplication

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cc573ea9039ac3aeb556c7a0f736f0c2d89b171f
---

 modules/text_renderer/freetype/fonts/win32.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/modules/text_renderer/freetype/fonts/win32.c b/modules/text_renderer/freetype/fonts/win32.c
index 522695544d..8b5f22c67c 100644
--- a/modules/text_renderer/freetype/fonts/win32.c
+++ b/modules/text_renderer/freetype/fonts/win32.c
@@ -334,6 +334,7 @@ struct enumFontCallbackContext
 {
     vlc_font_select_t *fs;
     vlc_family_t *p_family;
+    WCHAR prevFullName[LF_FULLFACESIZE];
 };
 
 static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *lpelfe, const NEWTEXTMETRICEX *metric,
@@ -345,20 +346,20 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *lpelfe, const NEWTEXTM
     struct enumFontCallbackContext *ctx = ( struct enumFontCallbackContext * ) lParam;
     vlc_family_t *p_family = ctx->p_family;
 
-    int i_flags = 0;
-    if( lpelfe->elfLogFont.lfWeight >= FW_BOLD )
-        i_flags |= VLC_FONT_FLAG_BOLD;
-    if( lpelfe->elfLogFont.lfItalic != 0 )
-        i_flags |= VLC_FONT_FLAG_ITALIC;
-
     /*
      * This function will be called by Windows as many times for each font
      * of the family as the number of scripts the font supports.
      * Check to avoid duplicates.
      */
-    for( vlc_font_t *p_font = p_family->p_fonts; p_font; p_font = p_font->p_next )
-        if( p_font->i_flags == i_flags )
-            return 1;
+    if( !wcscmp( ctx->prevFullName, lpelfe->elfFullName ) )
+        return 1;
+    wcscpy( ctx->prevFullName, lpelfe->elfFullName );
+
+    int i_flags = 0;
+    if( lpelfe->elfLogFont.lfWeight >= FW_BOLD )
+        i_flags |= VLC_FONT_FLAG_BOLD;
+    if( lpelfe->elfLogFont.lfItalic != 0 )
+        i_flags |= VLC_FONT_FLAG_ITALIC;
 
     char *psz_filename = NULL;
     char *psz_fontfile = NULL;
@@ -424,6 +425,7 @@ int Win32_GetFamily( vlc_font_select_t *fs, const char *psz_lcname, const vlc_fa
     struct enumFontCallbackContext ctx;
     ctx.fs = fs;
     ctx.p_family = p_family;
+    ctx.prevFullName[0] = 0;
     EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)&EnumFontCallback, (LPARAM)&ctx, 0);
     ReleaseDC(NULL, hDC);
 



More information about the vlc-commits mailing list