-
Bug
-
Resolution: Duplicate
-
P4
-
8
-
None
-
generic
-
generic
This is a SUNBUG for https://bugs.openjdk.java.net/show_bug.cgi?id=100134
Description From Mario T:
Created an attachment (id=179) [details]
Screenshot showing the incorrect behaviour
There is a bug in the Freetype scaler that causes fonts to be rendered at times
with the wrong metrics, resulting in an off-by-one, cutting the last pixel of
the fonts. This is particularly noticeable with underscore ('_') characters and
characters that have an extended glyphs height (like 'g').
I believe this to be a rounding error because the code seems to perform many
fixed-to-floating-point conversion and back between native and java code.
FontDesignMetrics.java provides a variable that is used to add a compensation.
The current value is 0.95f but it seems to not be enough. Increasing this value
to 1.0f seems to fix the issue.
Alternatively, there is code in freetypeScaler.c that may benefit of adding a
rounding up value.
The attached patch increses the value of the roundingUp in FontDesignMetrics,
because I think this is the less invasive fix, but I'm not sure if this patch
fixes the problem for any general case.
A screenshot with the faulty and correct behaviour is attached as well. The bug
seems to only affect OpenJDK.
A quick way to test this bug is to use the Font2DTest application.
Comment #1 From Mario T:
Webrev with proposed patch at
http://cr.openjdk.java.net/~neugens/100134/webrev.00/
Description From Mario T:
Created an attachment (id=179) [details]
Screenshot showing the incorrect behaviour
There is a bug in the Freetype scaler that causes fonts to be rendered at times
with the wrong metrics, resulting in an off-by-one, cutting the last pixel of
the fonts. This is particularly noticeable with underscore ('_') characters and
characters that have an extended glyphs height (like 'g').
I believe this to be a rounding error because the code seems to perform many
fixed-to-floating-point conversion and back between native and java code.
FontDesignMetrics.java provides a variable that is used to add a compensation.
The current value is 0.95f but it seems to not be enough. Increasing this value
to 1.0f seems to fix the issue.
Alternatively, there is code in freetypeScaler.c that may benefit of adding a
rounding up value.
The attached patch increses the value of the roundingUp in FontDesignMetrics,
because I think this is the less invasive fix, but I'm not sure if this patch
fixes the problem for any general case.
A screenshot with the faulty and correct behaviour is attached as well. The bug
seems to only affect OpenJDK.
A quick way to test this bug is to use the Font2DTest application.
Comment #1 From Mario T:
Webrev with proposed patch at
http://cr.openjdk.java.net/~neugens/100134/webrev.00/
- duplicates
-
JDK-6961732 FontMetrics.getLeading() may be negative in freetype-based OpenJDK builds
-
- Closed
-