[OpenJDK 2D-Dev] Fonts rendering in openjdk

Roman Kennke Roman.Kennke at Sun.COM
Sat May 15 21:52:22 UTC 2010


> 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

> 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

More information about the 2d-dev mailing list