On Wed, 10 Mar 2021 12:55:34 GMT, Matthias Baesken <[email protected]> wrote:
>> src/java.desktop/share/classes/java/awt/font/TextJustifier.java line 159:
>>
>>> 157: // predivide delta by weight
>>> 158: float weightedDelta = 0;
>>> 159: if (weight != 0) { // not used if weight == 0
>>
>> Can it ever be -ve? Maybe we can do weight > 0 check just as we do for
>> absorbweight?
>
> Hi, I am not sure about the weight > 0 check ; weight is initialized with
> 0: weight = 0; and later some values are potentially added up to weight:
> weight += gi.weight;
> I am not sure about those gi.weight values, maybe they can be negative too ?
Nothing throws an exception or otherwise prevent this being negative but that
would be a weird usage. Typically the weight is either zero or based on the
font size .. which ought not to be negative but I don't think anything prevents
it and I think we would treat it essentially as a transform. So If you really
want to be careful here, then yes assume weight could be negative.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2912