[vlc-commits] text_renderer/freetype: FontConfig_GetFamily: simplify bold/italic flags
Filip Roséen
git at videolan.org
Wed Mar 15 19:19:25 CET 2017
vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Mar 15 10:07:52 2017 +0100| [aa032f0ad9fb9842ebebcd937406479c9cc5350f] | committer: Hugo Beauzée-Luyssen
text_renderer/freetype: FontConfig_GetFamily: simplify bold/italic flags
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.
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa032f0ad9fb9842ebebcd937406479c9cc5350f
---
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 1165b34..fe097d0 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;
More information about the vlc-commits
mailing list