[vlc-devel] [PATCH] Freetype: fix calculation of max advance (fixes #20102)

Salah-Eddin Shaban salah at videolan.org
Mon May 28 10:20:58 CEST 2018


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.
---
 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;
 }
-- 
2.13.6



More information about the vlc-devel mailing list