[vlc-devel] [PATCH 1/1] freetype: handle non-English family and style names in Windows

Jean-Baptiste Kempf jb at videolan.org
Tue Nov 17 22:19:12 CET 2015


On 16 Nov, Salah-Eddin Shaban wrote :
> Close #6350

Once again, amazing work!

The patch was only opened 5(!) years ago.

Thanks again.

Just a remark:

> +static TCHAR *GetFullEnglishName( const ENUMLOGFONTEX *lpelfe )
> +{
> +
> +    /* FIXME: Try other combinations of platform/encoding/language IDs if necessary */
> +    if( GetSfntNameString( p_table, i_size, 3, 1, 4, 0x409, &p_name, &i_name_length) )
> +        goto done;
> +

>From here:
> +    int i_length_in_wchars = i_name_length / 2;
> +    wchar_t *psz_name = malloc( ( i_length_in_wchars + 1 ) * sizeof( *psz_name ) );
> +
> +    if( !psz_name )
> +        goto done;
> +
> +    for( int i = 0; i < i_length_in_wchars; ++i )
> +        psz_name[ i ] = U16_AT( p_name + i * 2 );
> +    psz_name[ i_length_in_wchars ] = 0;
> +
> +#ifdef UNICODE
> +    psz_result = psz_name;
> +#else
> +    psz_result = FromWide( psz_name );
> +    free( psz_name );
> +#endif

To here, this code seems a bit too complicated for what it does.
And I'm not 100% sure that the code is always valid.

Can't you use _tcsncpy and add the 0 at the end?

With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the vlc-devel mailing list