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

Philip Race philip.race at oracle.com
Tue May 19 04:56:53 UTC 2020



On 5/18/20, 9:29 PM, Sergey Bylokhov wrote:
> 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);

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

no.

>
> 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
>
well, there's the the issue that TL should not barf, but it does.

-phil.

>
> 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.
>
>


More information about the 2d-dev mailing list