[vlc-devel] [PATCH] text_renderer/freetype: FontConfig_GetFamily: simplify bold/italic flags
Filip Roséen
filip at atch.se
Wed Mar 15 10:07:52 CET 2017
The previous implementation would result in a diagnostic from gcc due
to it being unable to prove that b_bold and b_italic was always
initialized before usage.
These changes get rid of the diagnostic, while also simplifying the
implementation. A comment was added to make the purpose of the loop
clear.
---
modules/text_renderer/freetype/fonts/fontconfig.c | 25 +++--------------------
1 file changed, 3 insertions(+), 22 deletions(-)
diff --git a/modules/text_renderer/freetype/fonts/fontconfig.c b/modules/text_renderer/freetype/fonts/fontconfig.c
index 1165b34e2c..fe097d0db6 100644
--- a/modules/text_renderer/freetype/fonts/fontconfig.c
+++ b/modules/text_renderer/freetype/fonts/fontconfig.c
@@ -103,29 +103,10 @@ const vlc_family_t *FontConfig_GetFamily( filter_t *p_filter, const char *psz_fa
if( !p_family )
return NULL;
- bool b_bold, b_italic;
-
- for( int i = 0; i < 4; ++i )
+ for( int i = 0; i < 4; ++i ) /* Iterate through FC_{SLANT,WEIGHT} combos */
{
- switch( i )
- {
- case 0:
- b_bold = false;
- b_italic = false;
- break;
- case 1:
- b_bold = true;
- b_italic = false;
- break;
- case 2:
- b_bold = false;
- b_italic = true;
- break;
- case 3:
- b_bold = true;
- b_italic = true;
- break;
- }
+ bool const b_bold = i & 1;
+ bool const b_italic = i & 2;
int i_index = 0;
FcResult result = FcResultMatch;
--
2.12.0
More information about the vlc-devel
mailing list