[vlc-commits] Freetype: fix calculation of max advance

Salah-Eddin Shaban git at videolan.org
Wed Jun 27 14:07:27 CEST 2018


vlc/vlc-3.0 | branch: master | Salah-Eddin Shaban <salah at videolan.org> | Mon May 28 11:20:58 2018 +0300| [050f12cf3f52dc8a5203528347729ebb6f1a0ecd] | committer: Jean-Baptiste Kempf

Freetype: fix calculation of max advance

Some fonts like Sakkal Majalla have a large max_advance_width, apparently due to some glyphs that are rarely if ever used. This was causing "Invalid max width" errors for text that did fit the available width.

So the calculation of max advance has been modified to take into account only the glyphs we are actually rendering.

Fixes #20102

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit c47d0c4df2d3735cdf4bb4abc812a2c6befdb523)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/text_renderer/freetype/text_layout.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 1997492fa6..6a5d101a41 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -1037,11 +1037,11 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
                 p_bitmaps->i_x_advance = p_face->glyph->advance.x;
                 p_bitmaps->i_y_advance = p_face->glyph->advance.y;
             }
-        }
 
-        int i_max_run_advance_x = FT_FLOOR( FT_MulFix( p_face->max_advance_width, p_face->size->metrics.x_scale ) );
-        if( i_max_run_advance_x > *pi_max_advance_x )
-            *pi_max_advance_x = i_max_run_advance_x;
+            unsigned i_x_advance = FT_FLOOR( p_bitmaps->i_x_advance );
+            if( i_x_advance > *pi_max_advance_x )
+                *pi_max_advance_x = i_x_advance;
+        }
     }
     return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list