[vlc-commits] text_style: add DOUBLE_WIDTH

Francois Cartegnie git at videolan.org
Thu Jan 26 19:56:08 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jan 26 19:21:12 2017 +0100| [c88faa3c81c791d640ee8f5a05370e3f35dcd835] | committer: Francois Cartegnie

text_style: add DOUBLE_WIDTH

so we can match all width/height combinations
using width modifiers and font size scaling.

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

 include/vlc_text_style.h                        |  1 +
 modules/text_renderer/freetype/platform_fonts.c |  7 +++++--
 modules/text_renderer/freetype/text_layout.c    | 10 ++++++----
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/vlc_text_style.h b/include/vlc_text_style.h
index 1716163..b225a48 100644
--- a/include/vlc_text_style.h
+++ b/include/vlc_text_style.h
@@ -98,6 +98,7 @@ typedef struct
 #define STYLE_STRIKEOUT         (1 << 6)
 #define STYLE_HALFWIDTH         (1 << 7)
 #define STYLE_MONOSPACED        (1 << 8)
+#define STYLE_DOUBLEWIDTH       (1 << 9)
 
 #define STYLE_DEFAULT_FONT_SIZE 20
 #define STYLE_DEFAULT_REL_FONT_SIZE 6.25
diff --git a/modules/text_renderer/freetype/platform_fonts.c b/modules/text_renderer/freetype/platform_fonts.c
index bbd86fc..4ea648f 100644
--- a/modules/text_renderer/freetype/platform_fonts.c
+++ b/modules/text_renderer/freetype/platform_fonts.c
@@ -56,8 +56,11 @@ static FT_Face LoadFace( filter_t *p_filter, const char *psz_fontfile, int i_idx
     char *psz_key = NULL;
 
     int i_font_size  = ConvertToLiveSize( p_filter, p_style );
-    int i_font_width = p_style->i_style_flags & STYLE_HALFWIDTH ?
-                       i_font_size / 2 : i_font_size;
+    int i_font_width = i_font_size;
+    if( p_style->i_style_flags & STYLE_HALFWIDTH )
+        i_font_width /= 2;
+    else if( p_style->i_style_flags & STYLE_DOUBLEWIDTH )
+        i_font_width *= 2;
 
     if( asprintf( &psz_key, "%s - %d - %d - %d",
                   psz_fontfile, i_idx,
diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 14cf7f1..8726167 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -572,7 +572,7 @@ static bool FaceStyleEquals( filter_t *p_filter, const text_style_t *p_style1,
     if( p_style1 == p_style2 )
         return true;
 
-    const int i_style_mask = STYLE_BOLD | STYLE_ITALIC | STYLE_HALFWIDTH;
+    const int i_style_mask = STYLE_BOLD | STYLE_ITALIC | STYLE_HALFWIDTH | STYLE_DOUBLEWIDTH;
 
     const char *psz_fontname1 = p_style1->i_style_flags & STYLE_MONOSPACED
                               ? p_style1->psz_monofontname : p_style1->psz_fontname;
@@ -1134,9 +1134,11 @@ static int LayoutLine( filter_t *p_filter,
             p_style = p_run->p_style;
             p_face = p_run->p_face;
 
-            i_font_size = ConvertToLiveSize( p_filter, p_style );
-            i_font_width = p_style->i_style_flags & STYLE_HALFWIDTH ?
-                           i_font_size / 2 : i_font_size;
+            i_font_width = i_font_size = ConvertToLiveSize( p_filter, p_style );
+            if( p_style->i_style_flags & STYLE_HALFWIDTH )
+                i_font_width /= 2;
+            else if( p_style->i_style_flags & STYLE_DOUBLEWIDTH )
+                i_font_width *= 2;
         }
 
         FT_Vector pen_new = {



More information about the vlc-commits mailing list