[OpenJDK 2D-Dev] Fonts rendering in openjdk

Aekold Helbrass helbrass at gmail.com
Mon May 17 12:44:33 UTC 2010

Hi again!

Thanx for you fast and informative responses!

But now I am a bit confused. Roman tells that Freetype does the
rendering, but there is significant difference between Qt apps and
Java apps. See screenthos in attachments.

I found native code that works with freetype and changed glyph loading
flags to the same as Qt has (i debugged it too), but they became even

Phil, why pisces isn't appropriate for B&W or LCD text? Just interesting...

Point me please to right direction - to make Java font rendering
closer to Qt's should I learn pisces and compare it to Qt's rendering
or should I debug freetype invocations?

snapshot11 - tiny java app with DejaVu Sans Mono, Plain, 12 size font.
snapshot12 - the same font of size 10 in KWrite.
I assume that size (and roundness) difference is because of 72 DPI in
Java and 96 in KDE, but difference in antialiasing is obvious.

On 5/16/10, Phil Race <philip.race at oracle.com> wrote:
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapshot11.png
Type: image/png
Size: 5625 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20100517/cf51c746/snapshot11.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapshot12.png
Type: image/png
Size: 3621 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20100517/cf51c746/snapshot12.png>

More information about the 2d-dev mailing list