freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] Issues regarding converting READ_UINT4 function into FT.


From: Werner LEMBERG
Subject: Re: [ft-devel] Issues regarding converting READ_UINT4 function into FT.
Date: Sun, 24 Jun 2018 22:33:31 +0200 (CEST)

> I have been working on converting the file functions in the gf
> driver into FT specific stream functions.  [...]
> 
>   unsigned long
>   gf_read_uintn(FT_Stream stream, int size)
>   {
>     unsigned long  v;
>     FT_Error error = FT_Err_Ok;
>     v = 0L;
>     while (size >= 1)
>     {
>       v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
>       stream->pos-=3;

???  The `v*256' only makes sense if you read a single byte in the
loop!  If you read 4 bytes in a loop, the value must be
v*256*256*256*256.

>       --size;
>     }
>     return v;
>   }

You also have to take care of the byte order in GF files if you read
more than a single byte.

Finally, it's not clear to me why you directly use
`FT_Stream_ReadULong' and not one of the many macros like
`FT_READ_ULONG' (or `FT_READ_ULONG_LE').  I strongly suggest that you
imitate code present in other font modules.  Don't reinvent the
wheel...


    Werner



reply via email to

[Prev in Thread] Current Thread [Next in Thread]