[vlc-commits] freetype: use flags for font style

2020-08-24 Thread Francois Cartegnie
vlc | branch: master | Francois Cartegnie  | Wed Aug 12 
17:06:28 2020 +0200| [a9678ca64e73b50cf1214de5bdddb89eb444f690] | committer: 
Francois Cartegnie

freetype: use flags for font style

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

 modules/text_renderer/freetype/fonts/android.c| 25 +-
 modules/text_renderer/freetype/fonts/darwin.c | 13 
 modules/text_renderer/freetype/fonts/dwrite.cpp   |  9 +++--
 modules/text_renderer/freetype/fonts/fontconfig.c |  4 +--
 modules/text_renderer/freetype/fonts/win32.c  | 11 ---
 modules/text_renderer/freetype/freetype.c | 10 +++---
 modules/text_renderer/freetype/platform_fonts.c   | 40 ---
 modules/text_renderer/freetype/platform_fonts.h   | 14 
 8 files changed, 66 insertions(+), 60 deletions(-)

diff --git a/modules/text_renderer/freetype/fonts/android.c 
b/modules/text_renderer/freetype/fonts/android.c
index d1651ed083..40e47752b8 100644
--- a/modules/text_renderer/freetype/fonts/android.c
+++ b/modules/text_renderer/freetype/fonts/android.c
@@ -50,8 +50,7 @@
 static int Android_ParseFont( vlc_font_select_t *fs, xml_reader_t *p_xml,
   vlc_family_t *p_family )
 {
-bool  b_bold  = false;
-bool  b_italic= false;
+int   i_flags = 0;
 const char   *psz_val = NULL;
 const char   *psz_attr= NULL;
 int   i_type  = 0;
@@ -63,11 +62,11 @@ static int Android_ParseFont( vlc_font_select_t *fs, 
xml_reader_t *p_xml,
 i_weight = atoi( psz_val );
 else if( !strcasecmp( "style", psz_attr ) && psz_val && *psz_val )
 if( !strcasecmp( "italic", psz_val ) )
-b_italic = true;
+i_flags |= VLC_FONT_FLAG_ITALIC;
 }
 
 if( i_weight == 700 )
-b_bold = true;
+i_flags |= VLC_FONT_FLAG_BOLD;
 
 i_type = xml_ReaderNextNode( p_xml, _val );
 
@@ -84,7 +83,7 @@ static int Android_ParseFont( vlc_font_select_t *fs, 
xml_reader_t *p_xml,
  */
 if( i_weight == 400 || i_weight == 700 )
 if( asprintf( _fontfile, "%s/%s", SYSTEM_FONT_PATH, psz_val ) < 0
- || !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) )
+ || !NewFont( psz_fontfile, 0, i_flags, p_family ) )
 return VLC_ENOMEM;
 
 return VLC_SUCCESS;
@@ -224,8 +223,6 @@ static int Android_Legacy_ParseFamily( vlc_font_select_t 
*fs, xml_reader_t *p_xm
 vlc_family_t *p_family= NULL;
 char *psz_lc  = NULL;
 int   i_counter   = 0;
-bool  b_bold  = false;
-bool  b_italic= false;
 const char   *p_node  = NULL;
 int   i_type  = 0;
 
@@ -301,23 +298,19 @@ static int Android_Legacy_ParseFamily( vlc_font_select_t 
*fs, xml_reader_t *p_xm
 if( unlikely( !p_family ) )
 return VLC_ENOMEM;
 
+int i_flags = 0;
 switch( i_counter )
 {
 case 0:
-b_bold = false;
-b_italic = false;
 break;
 case 1:
-b_bold = true;
-b_italic = false;
+i_flags = VLC_FONT_FLAG_BOLD;
 break;
 case 2:
-b_bold = false;
-b_italic = true;
+i_flags = VLC_FONT_FLAG_ITALIC;
 break;
 case 3:
-b_bold = true;
-b_italic = true;
+i_flags = VLC_FONT_FLAG_BOLD | VLC_FONT_FLAG_ITALIC;
 break;
 default:
 msg_Warn( fs->p_obj, "Android_ParseFamily: too many files" 
);
@@ -326,7 +319,7 @@ static int Android_Legacy_ParseFamily( vlc_font_select_t 
*fs, xml_reader_t *p_xm
 
 char *psz_fontfile = NULL;
 if( asprintf( _fontfile, "%s/%s", SYSTEM_FONT_PATH, p_node 
) < 0
- || !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) )
+ || !NewFont( psz_fontfile, 0, i_flags, p_family ) )
 return VLC_ENOMEM;
 
 ++i_counter;
diff --git a/modules/text_renderer/freetype/fonts/darwin.c 
b/modules/text_renderer/freetype/fonts/darwin.c
index 08a9f1c88d..53c8e5e724 100644
--- a/modules/text_renderer/freetype/fonts/darwin.c
+++ b/modules/text_renderer/freetype/fonts/darwin.c
@@ -58,29 +58,30 @@ static char* getPathForFontDescription(CTFontDescriptorRef 
fontDescriptor)
 
 static void addNewFontToFamily(vlc_font_select_t *fs, CTFontDescriptorRef 
iter, char *path, vlc_family_t *p_family)
 {
-bool b_bold = false;
-bool b_italic = false;
+int i_flags = 0;
 CFDictionaryRef fontTraits = CTFontDescriptorCopyAttribute(iter, 

[vlc-commits] freetype: use flags for font style

2020-08-24 Thread Francois Cartegnie
vlc | branch: master | Francois Cartegnie  | Wed Aug 12 
17:06:28 2020 +0200| [9fb090083cb8388152303401f308b9c3b52815da] | committer: 
Francois Cartegnie

freetype: use flags for font style

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

 modules/text_renderer/freetype/fonts/android.c| 25 +-
 modules/text_renderer/freetype/fonts/darwin.c | 13 
 modules/text_renderer/freetype/fonts/dwrite.cpp   |  9 +++--
 modules/text_renderer/freetype/fonts/fontconfig.c |  4 +--
 modules/text_renderer/freetype/fonts/win32.c  | 11 ---
 modules/text_renderer/freetype/freetype.c | 10 +++---
 modules/text_renderer/freetype/platform_fonts.c   | 40 ---
 modules/text_renderer/freetype/platform_fonts.h   | 14 
 8 files changed, 66 insertions(+), 60 deletions(-)

diff --git a/modules/text_renderer/freetype/fonts/android.c 
b/modules/text_renderer/freetype/fonts/android.c
index d1651ed083..40e47752b8 100644
--- a/modules/text_renderer/freetype/fonts/android.c
+++ b/modules/text_renderer/freetype/fonts/android.c
@@ -50,8 +50,7 @@
 static int Android_ParseFont( vlc_font_select_t *fs, xml_reader_t *p_xml,
   vlc_family_t *p_family )
 {
-bool  b_bold  = false;
-bool  b_italic= false;
+int   i_flags = 0;
 const char   *psz_val = NULL;
 const char   *psz_attr= NULL;
 int   i_type  = 0;
@@ -63,11 +62,11 @@ static int Android_ParseFont( vlc_font_select_t *fs, 
xml_reader_t *p_xml,
 i_weight = atoi( psz_val );
 else if( !strcasecmp( "style", psz_attr ) && psz_val && *psz_val )
 if( !strcasecmp( "italic", psz_val ) )
-b_italic = true;
+i_flags |= VLC_FONT_FLAG_ITALIC;
 }
 
 if( i_weight == 700 )
-b_bold = true;
+i_flags |= VLC_FONT_FLAG_BOLD;
 
 i_type = xml_ReaderNextNode( p_xml, _val );
 
@@ -84,7 +83,7 @@ static int Android_ParseFont( vlc_font_select_t *fs, 
xml_reader_t *p_xml,
  */
 if( i_weight == 400 || i_weight == 700 )
 if( asprintf( _fontfile, "%s/%s", SYSTEM_FONT_PATH, psz_val ) < 0
- || !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) )
+ || !NewFont( psz_fontfile, 0, i_flags, p_family ) )
 return VLC_ENOMEM;
 
 return VLC_SUCCESS;
@@ -224,8 +223,6 @@ static int Android_Legacy_ParseFamily( vlc_font_select_t 
*fs, xml_reader_t *p_xm
 vlc_family_t *p_family= NULL;
 char *psz_lc  = NULL;
 int   i_counter   = 0;
-bool  b_bold  = false;
-bool  b_italic= false;
 const char   *p_node  = NULL;
 int   i_type  = 0;
 
@@ -301,23 +298,19 @@ static int Android_Legacy_ParseFamily( vlc_font_select_t 
*fs, xml_reader_t *p_xm
 if( unlikely( !p_family ) )
 return VLC_ENOMEM;
 
+int i_flags = 0;
 switch( i_counter )
 {
 case 0:
-b_bold = false;
-b_italic = false;
 break;
 case 1:
-b_bold = true;
-b_italic = false;
+i_flags = VLC_FONT_FLAG_BOLD;
 break;
 case 2:
-b_bold = false;
-b_italic = true;
+i_flags = VLC_FONT_FLAG_ITALIC;
 break;
 case 3:
-b_bold = true;
-b_italic = true;
+i_flags = VLC_FONT_FLAG_BOLD | VLC_FONT_FLAG_ITALIC;
 break;
 default:
 msg_Warn( fs->p_obj, "Android_ParseFamily: too many files" 
);
@@ -326,7 +319,7 @@ static int Android_Legacy_ParseFamily( vlc_font_select_t 
*fs, xml_reader_t *p_xm
 
 char *psz_fontfile = NULL;
 if( asprintf( _fontfile, "%s/%s", SYSTEM_FONT_PATH, p_node 
) < 0
- || !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) )
+ || !NewFont( psz_fontfile, 0, i_flags, p_family ) )
 return VLC_ENOMEM;
 
 ++i_counter;
diff --git a/modules/text_renderer/freetype/fonts/darwin.c 
b/modules/text_renderer/freetype/fonts/darwin.c
index 08a9f1c88d..53c8e5e724 100644
--- a/modules/text_renderer/freetype/fonts/darwin.c
+++ b/modules/text_renderer/freetype/fonts/darwin.c
@@ -58,29 +58,30 @@ static char* getPathForFontDescription(CTFontDescriptorRef 
fontDescriptor)
 
 static void addNewFontToFamily(vlc_font_select_t *fs, CTFontDescriptorRef 
iter, char *path, vlc_family_t *p_family)
 {
-bool b_bold = false;
-bool b_italic = false;
+int i_flags = 0;
 CFDictionaryRef fontTraits = CTFontDescriptorCopyAttribute(iter,