[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] Possibly a bug
From: |
Ulf Ochsenfahrt |
Subject: |
[Devel] Possibly a bug |
Date: |
Tue, 16 Apr 2002 11:16:16 +0200 (MEST) |
Hi,
I do have a problem with the FreeType library.
I have RedHat 7.2 and have tested both 2.0.3 and 2.0.9.
My problem is the following:
I am writing an import unit for FreePascal (1.0.4) under Linux and I get
very interesting problems. The import unit itself works - in a way. I have
already rendered single characters - no problem. But then I tried rendering
several (say two) letters and it crashes every time. I stripped the program down
to:
FT_Init_FreeType(alibrary);
FT_New_Face(alibrary, 'test1.ttf', 0, face);
FT_Set_Pixel_Sizes(face, 8, 16);
// No problem so far.
FT_Load_Char(face, 65, 0);
FT_Load_Char(face, 65, 0);
// Now crash!
FT_Render_Glyph(face^.glyph, 0);
...
When FT_Load_Char is called only once, no problem, the character is rendered
and I can display it - looks really good, yeah ! -, but when it is called
twice, it crashes in FT_Render_Glyph.
I then looked into the data structures after the two calls of FT_Load_Char.
The first time everything is alright, the second time face->glyph.metrics is
almost completely trash, horiAdvance and vertAdvance are still correct, but
the other values are completely wrong.
metrics.width: 151001472
metrics.height: 285217024
metrics.horiBearingX: -64
metrics.horiBearingY: 285217024
metrics.horiAdvance: 448 <- correct
metrics.vertBearingX: -75500736
metrics.vertBearingY: -285216256
metrics.vertAdvance: 1152 <- correct
I thought that it might be a problem with the calling convention. So - I
wrote the same program in C and it works. I compared the assembler code of both
programs. It was actually different. (C always pushes at least 16 bytes on
the stack before calling a function. FP only pushes as many bytes as the amount
of parameters dictates.) FreePascal is able to compile assembler code, so I
wrote the program in FreePascal in Assembler -> Crash.
I thought it could be a problem with the memory management, but between the
two calls to FT_Load_Char there is NO memory access - at least not from the
point of FreePascal.
I thought it could be a problem with the font file. So I tried two other
font files -> same problem.
I tried the same program without modifications under Windows using
FreePascal for Win32 and freetype.dll -> works perfectly.
Could it be that the library needs some library-initialization function
called that is automatically called by C but not be FP? But why does that only
make a difference for the second call? Possibly the memory management of C must
be initialized?
Can anyone help?
-- Ulf.
P.S.: The attachment is the FP import unit.
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
freetype.pas
Description: Binary data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Devel] Possibly a bug,
Ulf Ochsenfahrt <=