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

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


vlc | branch: master | Salah-Eddin Shaban <salah at videolan.org> | Mon May 28 11:20:58 2018 +0300| [c47d0c4df2d3735cdf4bb4abc812a2c6befdb523] | 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>

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

 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 b7c029d33d..8f50be1943 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -1148,11 +1148,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