Hi Jim, Roman, Java2D people, I'm trying to fix an annoying bug that appears almost always fonts are rendered without antialiasing:
http://www.limasoftware.net/neugens/downloads/stuff/font2dbug/bug.png I started tracking this because anything I write something with an underscore in NetBeans I don't see the underscore, and that drives me crazy (ok, it also affect JamaicaVM, but I fixed it because I type my code in NetBeans ;) My ideas was that the metrics are calculated incorrectly in presence of hinting [1]. The freetype documentation states that there can be an off-by-one (or more) in such cases. This made me check the freetype scaler native code and in turn the FontDesignMetrics. Now, by reading the code, I believe this to be a rounding error and not an off-by-one for the fixed-to-floating-point conversion and back that happens between native and java code, but it's still not 100% clear to me the reason and where the rounding goes off (the code is quite convoluted, or maybe it was just a too long day). I found two possible places where I could fix it, one is taking out the rounding from FontDesignMetrics [2]: private static float roundingUpValue = 0.0f and rounding the leading only in the freetypeScaler.c: ly = (jfloat) ROUND(FT26Dot6ToFloat( scalerInfo->face->size->metrics.height + bmodifier) + ay - dy); The other is to simply increase roundingUpValue to 1.0f. I would like some context around this, maybe those values were calculated for the closed font scaler and are not valid with freetype (maybe freetype does a better job with this even?) or maybe incrementing the rounding up does only fix the problem without fixing the cause (or worse, only for a selected group of fonts)? I'm a bit lost on that, so any hint (even subpixel ones :) is appreciated. Ah, before I forget, you can quickly test this with Open and ClosedJDK with the Font2DTest.jar and passing -Dawt.useSystemAAFontSettings=false Cheers, Mario [1] http://freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Size_Metrics) [2] http://www.limasoftware.net/neugens/downloads/stuff/font2dbug/possible_fix.png -- pgp key: http://subkeys.pgp.net/ Proud GNU Classpath developer: http://www.classpath.org/ Read About us at: http://planet.classpath.org OpenJDK: http://openjdk.java.net/projects/caciocavallo/ Please, support open standards: http://endsoftpatents.org/