[vlc-devel] [PATCH] freetype: render Arabic diacritics properly

Rémi Denis-Courmont remi at remlab.net
Tue Jan 6 20:29:58 CET 2015


Le mardi 06 janvier 2015, 13:42:08 Salah-Eddin Shaban a écrit :
> ---
>  modules/text_renderer/freetype.c | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/modules/text_renderer/freetype.c
> b/modules/text_renderer/freetype.c index 1670aa7..050ace6 100644
> --- a/modules/text_renderer/freetype.c
> +++ b/modules/text_renderer/freetype.c
> @@ -1361,6 +1361,10 @@ static int ProcessLines( filter_t *p_filter,
>              /* Render the part */
>              bool b_break_line = false;
>              int i_glyph_last = 0;
> +            FT_Vector advance = {
> +                .x = 0,
> +                .y = 0,
> +            };
>              while( i_part_length > 0 )
>              {
>                  const text_style_t *p_glyph_style = pp_styles[i_index];
> @@ -1373,6 +1377,16 @@ static int ProcessLines( filter_t *p_filter,
>                  if( i_glyph_index == 0 && character == 0xFEFF )
>                      goto next;
> 
> +/* These are the most common Arabic diacritics */
> +#define DIACRITIC( a ) ( a >= 0x064B && a <= 0x0653 )
> +
> +                /* Diacritics should be rendered over the preceding base
> glyph */
> +                if( DIACRITIC( character ) )
> +                {
> +                    pen.x -= advance.x;
> +                    pen.y -= advance.y;
> +                }
> +

As far as I know, the font is supposed to specify the relative position of a 
character to the previous one. That is not supposed to be hard-coded by the 
Unicode code point: combining characters do not look the same in all fonts.

So this seems too simplistic to be correct.

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list