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

Bernie Purcell berniepurcell at gmail.com
Thu Jan 22 23:59:53 CET 2015


Pretty sure it's part of glibc on linux. On OSX it should be part of the
command-line tools I think.

I don't know if there's a better or more standard way of doing this
myself. The more commonly seen cross platform header files that #include
it all seem to have #ifdef's around the include that aren't guaranteed
to be satisfied on all platforms.

If you're uncomfortable using this header file for that reason there are
some simple tests on Google to determine if you're on a big or little
endian system, as well as the builtin gcc compiler variables, eg.
__BYTE_ORDER__ which is either __ORDER_LITTLE_ENDIAN__ or
__ORDER_BIG_ENDIAN__ that you could use those to ifdef your original
code instead.


On 22/01/15 21:00, Salah-Eddin Shaban wrote:
> 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
> _______________________________________________
> 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