nanogui: freetype2 now works
Subject:
freetype2 now works
From:
"Paul Bartholomew" ####@####.####
Date:
7 Jul 2005 21:11:11 +0100
Message-Id: <BAY108-F19D024F16224370E0CEABCEFD80@phx.gbl>
Hello -
I'm using the latest Microwindows/Nano-X from CVS, and have found
several problems with the "FreeType 2" support (engine/font_freetype2.c):
- Starting with FT version 2.1.8, the "ImageTypeRec" structure
was changed. Because of this, "font_freetype2.c" won't compile
when "HAVE_FREETYPE_2_CACHE" is set to "1"
- Setting "HAVE_FREETYPE_2_CACHE" to "0" causes compile errors
in "font_freetype2.c" (regardless of FreeType version)
- Starting with FT version 2.1.5, the "FAST" code in
"freetype2_drawtext()" doesn't work (nothing is displayed).
This "FAST" code is only used when the font's rotation angle
is "0" (non-rotated). Using the "SLOW" version always works
(even if angle is "0").
- The "FAST" code in "freetype2_drawtext()" *does* work in
FT version 2.1.4 and earlier, but only when MWTF_BASELINE
is used. For MWTF_TOP and MWTF_BOTTOM, the code was
adjusting the "y" position in the wrong direction (adding
a "y" offset instead of subtracting).
- "freetype2_setfontrotation()" was computing the wrong
transformation matrix for non-zero angles (it was +90 degrees
off, as compared to the code in "engine/font_freetype.c" (FT 1)).
I've modified "engine/font_freetype2.c" to 'fix' all of these
problems. Some of the 'fixes' aren't really fixing the problem -
they just avoid them. For example, if using FT version 2.1.5
or higher, I disable the "FAST" version of "freetype2_drawtext()".
Also, if using FT version 2.1.8 or higher, I force
"HAVE_FREETYPE_2_CACHE" to be "0" (which now works, because I've
fixed the compile errors that used to occur in this case).
With my changes, the "ftdemo" app using FreeType 2 now operates
the same as when using "FreeType 1" (1.3.1) (text alignment,
rotation angles are the same). I've tested this with "FreeType 2"
versions 2.1.3, 2.1.5, 2.1.7, 2.1.8, and 2.1.10.
(It shouldn't make a difference, but my build environment is
"Fedora Core 4" (x86))
I've attached a new version of "engine/font_freetype2.c", as well
as a "diff" output (comparing to CVS version as of
today: July 7, 2005).
Comment blocks in the code describe the version-specific stuff
I'm doing (as I mentioned above).
To fix the compile errors (when "HAVE_FREETYPE_2_CACHE" is "0"),
I added 2 arguments to "freetype2_createfont_internal()" (the pointer
to the bitmap and the bitmap size). These args are only used when
the 'filename' arg is NULL.
In "freetype2_setfontrotation()", I swapped the use of "sincosvec.x/.y"
to get the same results as the FreeType 1 version.
In "freetype2_drawtext()", I changed "ay += (pos.y >> 6)" to
"ay -= (pos.y >> 6)". This fixes the "FAST" draw code to work
with MWTF_TOP/MWTF_BOTTOM alignments.
Let me know if you find any problems.
- Paul
[Content type application/x-zip-compressed not shown. Download]