Expanding a little on Roman's comments :
freetype is a font scaler or rasteriser. eg It takes a TrueType font and
returns to
its requester a bitmap or greymap image, or a path describing the glyph
shape.
Its role does not extend to rendering (ie putting the results of
rasterisation
on a surface). This isn't an "openjdk thing". Its just that's the role
of freetype.
Yes it also obtains the metrics in most cases.
As Roman says there are specialised blitting routines for the text,
including
OpenGL pixel shader code, if that pipeline is optionally available and
enabled.
pisces isn't ever going to be the best (notably not the fastest) way to
get text
on screen and isn't appropriate for B&W or LCD text.
-phil.
Roman Kennke wrote:
Hello,
I want to hack into the sources of font rendering of openjdk, and I'm
a bit confused now. So help me please understand how it works. Links
are appreciated too.
I read that freetype is used for fonts scaling, but after debugging it
looks like freetype is used only to get font metrics, while real
rendering is done using Pisces. I know nothing about real font
rendering, so I have few questions about it:
1. am I right that freetype is used only to get font shapes while all
rendering and antialiasing is done using Pisces?
No, not really. The Java2D stack also gets the rendered glyphs from
Freetype as bitmaps. These are displayed by pisces similar to images.
2. isn't freetype can be used for font rendering and is used in GTK
and Qt? Or freetype is only scaler?
There's the interface FontScaler in the sources (search for it). If you
manage to implement this using GTK or Qt... AFAIK, GTK and Qt use
Freetype themselves, so there wouldn't be any significant improvement.
Plus, the FontScaler interface is quite low level, I guess you'd have a
hard time implementing this using GTK or Qt, which are somwhat
higher-level.
3. if freetype can be used for font rendering - why Pisces is used?
See above. Freetype does the actual rendering (anti-aliasing and such),
Pisces isn't really used, the resulting bitmaps are directly blitted to
the surface. Unless you're fetching the outlines and render them using
draw() or such, in this case freetype doesn't do the rendering. But
that's not the usual case.
4th and the most important - how are you guys debugging native code?
It's not supported with nbprojects, and I can't imagine how to launch
java with some application to debug some native code...
I prefer to use gdb. You can launch Java this way:
java -XX:OnError="gdb - %p" MyApplication
this jumps into gdb whenever something bad happens.
Kind regards, Roman