[OpenJDK 2D-Dev] RFR: 8203485: [freetype] text rotated on 180 degrees is too narrow
abrygin at azul.com
Tue May 22 15:50:43 UTC 2018
With freetype, text rotated on 180 or 270 degrees is too narrow.
Attached test case and screenshots demonstrate the problem.
The problem is caused by the rounding applied to the cases of vertical
and horizontal text, see freetypeScaler.c, lines 768 and 773:
The rounding routine is defined as ROUND(x) ((int) (x+0.5)) (see line 48),
and it gives incorrect results for negative arguments.
For example, say glyph advance is 8, and we render it without rotation,
and with rotation on 180 degrees. In these cases, we get ROUND(8) = 8,
whereas for 180 degrees we get ROUND(-8) = -7. This rounding error
leads to decrease of the width of the rendered text.
For the case of integer metrics, we can expect that FT26.6 advances
produced by freetype are integer, i.e. fractional part (lower 6 bits)
is zero. So, we can convert them to glyph info values without floating
point division, just by using integer shift. In this case, there is no
need to round the floating point value to integer, and there is no need
to care about sign of the argument.
More information about the 2d-dev