freetype: fix extra squares in Arabic subtitles (fixes #6152 #8117)
authorSalah-Eddin Shaban <salshaaban@gmail.com>
Mon, 5 Jan 2015 14:52:33 +0000 (14:52 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 5 Jan 2015 18:30:02 +0000 (19:30 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/text_renderer/freetype.c

index e562afc..1670aa7 100644 (file)
@@ -1367,6 +1367,12 @@ static int ProcessLines( filter_t *p_filter,
                 uni_char_t character = psz_text[i_index];
                 int i_glyph_index = FT_Get_Char_Index( p_current_face, character );
 
                 uni_char_t character = psz_text[i_index];
                 int i_glyph_index = FT_Get_Char_Index( p_current_face, character );
 
+                /* If the missing glyph is U+FEFF (ZERO WIDTH NO-BREAK SPACE) */
+                /* we can safely ignore it. Otherwise extra squares show up   */
+                /* in Arabic text.                                            */
+                if( i_glyph_index == 0 && character == 0xFEFF )
+                    goto next;
+
                 /* Get kerning vector */
                 FT_Vector kerning = { .x = 0, .y = 0 };
                 if( FT_HAS_KERNING( p_current_face ) && i_glyph_last != 0 && i_glyph_index != 0 )
                 /* Get kerning vector */
                 FT_Vector kerning = { .x = 0, .y = 0 };
                 if( FT_HAS_KERNING( p_current_face ) && i_glyph_last != 0 && i_glyph_index != 0 )