[Customdrawn] Trying "Customdrawn"

Giuliano Colla giuliano.colla at fastwebnet.it
Mon Apr 2 13:30:32 CEST 2012

Il 02/04/2012 11:31, Michael Schnell ha scritto:
> On 04/02/2012 10:56 AM, Michael Schnell wrote:
>> Maybe I can replace the the damn "with" notation by the actual 
>> variable names, to have the debugger show me the values.
> I did some test:
> in TTload Line 261:
> Loop with n = 0 runs fine
> n= 1:
> Tag is calculated to 1195656518
> it crashes within GetULong when calculating "Checksum"
> in GetUlong
> frame_cursor is 20
> current_frame shows lots of data
> at position 20 I see:
> 162, 64, 158, 152, 0, 0, 1, 88, ...
> It crashes when trying to leave the function GetULong,
> Here the Disassembly Window shows that after returning from GetUlong, 
> the code checks whether the result is negative (highest bit set) and 
> initializes a Range Check error in this case.
> This is correct, as Checksum is defined as a (signed) long.
> So I suppose the problem is that Checksum in Fact should be defined as 
> ULong. (Same supposedly is true for "Tag" as well).
> So for a try I changed the code in TTLoad to call GetLong() instead. 
> (acknowledging the supposedly erroneous fact that Checksum is signed)
> This overcomes this problem, but now I get the range check error in 
> line 498. when calling GetShort().
> This code quite obviously is a bit buggy.
> I suppose the working variant has been compiled with range check 
> disabled.
> I tried to disable range check in the project option, but I get the 
> range check exception nonetheless.

I'm more and more convinced that this isn't a bug in TTLoad itself, but 
a problem with fpc versions. If something has been changed, as far as 
Longint, Long/ULong and Short/Ushort or related definitions are 
concerned (maybe because of x86_64 support or something like that), this 
would explain a lot.
GetLong and GetUlong also increments a pointer of the size of Long, or 
ULong. But if there's a mismatch between the actual size of a field in 
the ttf file, and the expected size of the variable, then you either get 
a wrong type, or increment of the wrong amount (so that next test fails).
The problem is wether to fix TTLoad so that it works with fpc 2.7, or 
fix fpc 2.7 in order to make TTLoad work....

More information about the Customdrawn mailing list