[OpenJDK 2D-Dev] Font question

Phil Race Phil.Race at Sun.COM
Thu Apr 17 18:05:28 UTC 2008


Roman Kennke wrote:

> http://kennke.org/~roman/swingdemo.png
> This might be using different fonts, I'm not sure which fonts are used
> by default for DIALOG, etc. But OTOH, I don't have many fonts on my
> system and none of them looks good on the cacio pipeline.

On Ubuntu its using DejaVu Sans. See
and its clearly anti-aliased.

> Do you have a quick hint, how I can enable AA rasterization? As I said,
> I don't get any gray values in my rasterizer, only 0 and 255, even when
> the rendering hint is set to AA for text.

I'm not clear what you mean by 'your rasterizer'.
Ultimately you have to pass the right flags to freetype
See Java_sun_font_FreetypeFontScaler_getGlyphImageNative in freetypescaler.c
No matter how little of the following applies, you clearly at least have
to tell freetype the right thing to do.

In the OpenJDK architecture this means creating a FileFontStrike with
a FontStrikeDesc object which has the aa flag on.

The AA flag is taken from the RenderingHints on the Graphics2D, and
sun.java2d.SunGraphics2D.java has code in checkFontInfo(..) which
creates the FontStrikeDesc and FileFontStrike based on that and
the rest of the appropriate graphics state.


More information about the 2d-dev mailing list