<Swing Dev> [9] Review request for 8132119 Provide public API for text related methods in SwingUtilities2
Phil Race
philip.race at oracle.com
Tue Apr 26 21:34:16 UTC 2016
On 04/26/2016 01:39 PM, Sergey Bylokhov wrote:
> On 26.04.16 23:31, Alexander Scherbatiy wrote:
>>>> Now it is possible that width1 is not equal to width2.
>>>
>>> Absolutely true. And it is something Swing needs to handle.
>>
>> Even more, it is not will be possible to rely on the fact that width
>> of number of chars is just sum of each char width.
>>
>> For example, on graphics configuration with transform 2 the glyph
>> xAdvance can be 13 and the char width in user space will be calculated
>> as 13 / 2 = 6.5.
>> FontMetrics. charWidth('a') will return 7 and charsWidth(array of 10
>> 'a' ) will be 65 wich is not 7 * 10.
>
> 13 / 2 = 6.5 is a fractional data in the user's space and actually
> such data is a "bug" when the fractional metrics are off. This was
> discussed a few times when this bug was fixed on OSX. and CStrike code
> on osx was changed to handle fraction on/off in terms of user's
> space(not the actual device space=pixels). I guess there is no other
> solution other than that.
>
>
Fractional metrics being "off" does not mean that *user space* advances
need to be integers,
it refers to *device* space advances. Of course if your API does not
support floats you have a
problem - particularly if - you are character advance adding in which
case it is better to ask the
font system for the overall advance of the text.
https://docs.oracle.com/javase/8/docs/api/java/awt/RenderingHints.html#KEY_FRACTIONALMETRICS
-phil.
More information about the swing-dev
mailing list