[vlc-commits] freetype: get_face always checks codepoint
Francois Cartegnie
git at videolan.org
Tue Jul 7 21:12:28 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 6 09:11:09 2020 +0200| [3a79dc889d4e592955f85c20097be30856df9b40] | committer: Francois Cartegnie
freetype: get_face always checks codepoint
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3a79dc889d4e592955f85c20097be30856df9b40
---
modules/text_renderer/freetype/fonts/dwrite.cpp | 4 +--
modules/text_renderer/freetype/fonts/win32.c | 4 +--
modules/text_renderer/freetype/platform_fonts.c | 36 +++++++++++--------------
modules/text_renderer/freetype/platform_fonts.h | 2 +-
4 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/modules/text_renderer/freetype/fonts/dwrite.cpp b/modules/text_renderer/freetype/fonts/dwrite.cpp
index 943c60f3a2..1e4f168a02 100644
--- a/modules/text_renderer/freetype/fonts/dwrite.cpp
+++ b/modules/text_renderer/freetype/fonts/dwrite.cpp
@@ -793,9 +793,7 @@ extern "C" vlc_family_t *DWrite_GetFallbacks( filter_t *p_filter, const char *ps
if( !p_fallback || !p_fallback->p_fonts )
goto done;
- FT_Face p_face = GetFace( p_filter, p_fallback->p_fonts );
-
- if( !p_face || !FT_Get_Char_Index( p_face, codepoint ) )
+ if( !GetFace( p_filter, p_fallback->p_fonts, codepoint ) )
goto done;
p_family = NewFamily( p_filter, psz_fallback, NULL, NULL, NULL );
diff --git a/modules/text_renderer/freetype/fonts/win32.c b/modules/text_renderer/freetype/fonts/win32.c
index 23d3c4770d..e9b8f47b4e 100644
--- a/modules/text_renderer/freetype/fonts/win32.c
+++ b/modules/text_renderer/freetype/fonts/win32.c
@@ -552,9 +552,7 @@ vlc_family_t *Win32_GetFallbacks( filter_t *p_filter, const char *psz_family,
if( !p_uniscribe || !p_uniscribe->p_fonts )
goto done;
- FT_Face p_face = GetFace( p_filter, p_uniscribe->p_fonts );
-
- if( !p_face || !FT_Get_Char_Index( p_face, codepoint ) )
+ if( !GetFace( p_filter, p_uniscribe->p_fonts, codepoint ) );
goto done;
p_family = NewFamily( p_filter, psz_uniscribe, NULL, NULL, NULL );
diff --git a/modules/text_renderer/freetype/platform_fonts.c b/modules/text_renderer/freetype/platform_fonts.c
index f6baa8cb42..184c201718 100644
--- a/modules/text_renderer/freetype/platform_fonts.c
+++ b/modules/text_renderer/freetype/platform_fonts.c
@@ -136,17 +136,20 @@ done:
return p_face;
}
-FT_Face GetFace( filter_t *p_filter, vlc_font_t *p_font )
+FT_Face GetFace( filter_t *p_filter, vlc_font_t *p_font, uni_char_t codepoint )
{
filter_sys_t *p_sys = p_filter->p_sys;
- if( p_font->p_face )
- return p_font->p_face;
-
- p_font->p_face = LoadFace( p_filter, p_font->psz_fontfile, p_font->i_index,
- p_sys->p_default_style );
+ if( !p_font->p_face )
+ p_font->p_face = LoadFace( p_filter, p_font->psz_fontfile,
+ p_font->i_index,
+ p_sys->p_default_style );
- return p_font->p_face;
+ if( p_font->p_face &&
+ FT_Get_Char_Index( p_font->p_face, codepoint ) )
+ return p_font->p_face;
+ else
+ return NULL;
}
/**
@@ -169,12 +172,8 @@ static vlc_font_t *GetBestFont( filter_t *p_filter, const vlc_family_t *p_family
{
int i_score = 0;
- if( codepoint )
- {
- FT_Face p_face = GetFace( p_filter, p_font );
- if( p_face && FT_Get_Char_Index( p_face, codepoint ) )
- i_score += 1000;
- }
+ if( codepoint && GetFace( p_filter, p_font, codepoint ) )
+ i_score += 1000;
if( !!p_font->b_bold == !!b_bold )
i_score += 100;
@@ -209,9 +208,9 @@ vlc_family_t *SearchFallbacks( filter_t *p_filter, vlc_family_t *p_fallbacks,
p_fallback->p_fonts = p_temp->p_fonts;
}
- FT_Face p_face = GetFace( p_filter, p_fallback->p_fonts );
- if( !p_face || !FT_Get_Char_Index( p_face, codepoint ) )
+ if( !GetFace( p_filter, p_fallback->p_fonts, codepoint ) )
continue;
+
p_family = p_fallback;
break;
}
@@ -524,12 +523,9 @@ char* Generic_Select( filter_t *p_filter, const char* psz_family,
* It usually has the best coverage.
*/
const vlc_family_t *p_temp = p_sys->pf_get_family( p_filter, psz_family );
- if( p_temp && p_temp->p_fonts )
- {
- FT_Face p_face = GetFace( p_filter, p_temp->p_fonts );
- if( p_face && FT_Get_Char_Index( p_face, codepoint ) )
+ if( p_temp && p_temp->p_fonts &&
+ GetFace( p_filter, p_temp->p_fonts, codepoint ) )
p_family = p_temp;
- }
/* Try font attachments */
if( !p_family )
diff --git a/modules/text_renderer/freetype/platform_fonts.h b/modules/text_renderer/freetype/platform_fonts.h
index 4a38568586..e9c15eb578 100644
--- a/modules/text_renderer/freetype/platform_fonts.h
+++ b/modules/text_renderer/freetype/platform_fonts.h
@@ -297,7 +297,7 @@ int ConvertToLiveSize( filter_t *p_filter, const text_style_t *p_style );
/* Only for fonts implementors */
vlc_family_t *SearchFallbacks( filter_t *p_filter, vlc_family_t *p_fallbacks,
uni_char_t codepoint );
-FT_Face GetFace( filter_t *p_filter, vlc_font_t *p_font );
+FT_Face GetFace( filter_t *p_filter, vlc_font_t *p_font, uni_char_t codepoint );
#ifdef __cplusplus
}
More information about the vlc-commits
mailing list