[OpenJDK 2D-Dev] RFR: 8245159: Font.getStringBounds() throws IAE for empty string if the Font has layout attributes.

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Tue May 19 04:29:10 UTC 2020


Hi, Phil.

I guess the old code used TextLayout because the check above is "false":
boolean simple = values == null ||
     (values.getKerning() == 0 && values.getLigatures() == 0 &&
     values.getBaselineTransform() == null);

Is it possible that for the font which use attributes/kerning/ligatures the height
calculated via TextLayout and FontDesignMetrics.getSimpleBounds() will be different?

BTW what about the comment for this block:
    // this code should be in textlayout
    // quick check for simple text, assume GV ok to use if simple


On 5/18/20 5:07 pm, Philip Race wrote:
> bug : https://bugs.openjdk.java.net/browse/JDK-8245159
> webrev: http://cr.openjdk.java.net/~prr/8245159/
> 
> TextLayout does not like being constructed with an empty string, so
> when we accept a string from the application and  use it in
> creating a TextLayout we need to be check.
> I looked around for other cases that may be missing a check but did not spot any.
> 
> -phil.


-- 
Best regards, Sergey.


More information about the 2d-dev mailing list