[vlc-devel] [RFC PATCH] freetype: using Pango for text layout

Salah-Eddin Shaban salshaaban at gmail.com
Thu Jan 22 11:00:40 CET 2015


Thanks :)
I think you're right. It does seem like an endianness issue.

Is this the official way to handle such an issue? I mean is endian.h a
standard header on all platforms?

On Thu, Jan 22, 2015 at 1:00 AM, Bernie Purcell <berniepurcell at gmail.com> wrote:
> This looks suspiciously like an endian-conversion issue. I assume you're
> running on a Little-Endian system, like most PCs. If this code was run
> on Big-Endian it would possibly disrupt what was already in the format
> pango wanted. This is an assumption only - I don't actually know what
> pango really wants.
> I know you probably don't have a system running Big-Endian lying around
> the place to check on, so it's a bit hard to know for sure, but if I'm
> right some code like this might be better as it should only have an
> effect on the architecture that needs it.
>
> eg.
> #include <endian.h>
> ...
> for (int i=0; i< i_len; i++)
> {
>     psz_text[i] = htobe32(psz_text[i]);
> }
>
> bitmap
>
> On 21/01/15 12:26, Salah-Eddin Shaban wrote:
>> +    /*
>> +     * Convert to UTF-8 for Pango. psz_text is not recognized as
>> +     * UCS-4 unless the byte order is reversed.
>> +     */
>> +    for( int i = 0; i < i_len; ++i )
>> +    {
>> +        guchar *p = ( guchar * ) psz_text + i * sizeof( *psz_text );
>> +        guchar ch0 = *( p ); guchar ch1 = *( p + 1 );
>> +        guchar ch2 = *( p + 2 ); guchar ch3 = *( p + 3 );
>> +
>> +        *( p + 0 ) = ch3; *( p + 1 ) = ch2;
>> +        *( p + 2 ) = ch1; *( p + 3 ) = ch0;
>> +    }
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list