[vlc-commits] text_renderer: freetype: don't reparse from previous space

Francois Cartegnie git at videolan.org
Thu Jun 8 14:34:20 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun  7 16:49:07 2017 +0200| [1536d0cfe3afad726aef7fbd9c8f0bddc95f38a5] | committer: Francois Cartegnie

text_renderer: freetype: don't reparse from previous space

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

 modules/text_renderer/freetype/text_layout.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 1d32a83318..130ab69c60 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -1413,11 +1413,11 @@ static int LayoutParagraph( filter_t *p_filter, paragraph_t *p_paragraph,
         }
 
         const run_desc_t *p_run = &p_paragraph->p_runs[p_paragraph->pi_run_ids[i]];
+        const int i_advance_x = p_paragraph->p_glyph_bitmaps[ i ].i_x_advance;
 
-        i_width += p_paragraph->p_glyph_bitmaps[ i ].i_x_advance;
-
-        if( ( i_last_space_width >= i_preferred_width && p_run->p_style->e_wrapinfo == STYLE_WRAP_DEFAULT )
-         || i_width >= i_max_width )
+        if( ( i_last_space_width + i_advance_x >= i_preferred_width &&
+              p_run->p_style->e_wrapinfo == STYLE_WRAP_DEFAULT )
+            || i_width + i_advance_x >= i_max_width )
         {
             if( i_line_start == i )
             {
@@ -1449,11 +1449,17 @@ static int LayoutParagraph( filter_t *p_filter, paragraph_t *p_paragraph,
             }
 
             pp_line = &( *pp_line )->p_next;
-            i_line_start = i_newline_start;
-            i = i_line_start - 1;
-            i_width = 0;
+
+            /* If we created a line up to previous space, we only keep the difference for
+               our current width since that split */
+            if( i_newline_start == i_last_space )
+                i_width = i_width - i_last_space_width;
+            else
+                i_width = 0;
             i_last_space_width = 0;
+            i_line_start = i_newline_start;
         }
+        i_width += i_advance_x;
     }
 
     *pp_lines = p_first_line;



More information about the vlc-commits mailing list