CSS Font size in points doesn't match Node.Font.Size
david.grieve at oracle.com
Wed Mar 5 14:37:34 PST 2014
To set the record straight, everything in JavaFX is pixels, including
The W3C CSS spec (http://www.w3.org/TR/css3-values/#absolute-lengths)
defines 1px to be 1/96th of 1in and 1pt to be 1/72 of 1in. Therefore,
one px is 3/4ths of a pt (1px = 0.75pt) and this is the conversion
factor that JavaFX uses to convert CSS points to pixels.
That said, the W3C recommends against using pt, cm, mm, in and pc as
value units for screen media. Instead, you should use em, px or %. See
http://www.w3.org/Style/Examples/007/units.en.html for more details.
On 3/5/14, 5:03 PM, Felipe Heidrich wrote:
> The problem is that point size used by Node and point size used by CSS are not the same.
> One uses a 72 DPI and the other 96. Thus the final pixel sizes are different.
> I don’t see how to change one or the other without breaking a ton of people.
> Maybe adding a global font DPI so that Node can be made to match CSS ?
> Suggestions ?
> On Mar 5, 2014, at 12:39 PM, Pedro Duque Vieira <pedro.duquevieira at gmail.com> wrote:
>> Hi Tom, Jeff, Felipe...
>> Having bugs stay in to maintain backwards compatibility sounds very weird
>> to me IMHO.
>> If we go down that road aren't we creating a library that will some day
>> have too many glitches and as such less appeal to programmers looking for
>> UI libraries?
>>> On Mar 4, 2014, at 4:42 PM, Jeff Martin <jeff at reportmill.com> wrote:
>>>> Thanks Tom! I assume the thread was this one:
>>>> Font.font() says it is point size but it looks like it are pixels
>>>> I guess the final word is that CSS assumes 1pt==1/92in,
>>>> and Nodes convert that to the real world on render?
>>> On the printer yes, on the display it assumes 72 (pt=px).
>>>> And that this is basically a bug, but it can't be fixed due to legacy
>> Pedro Duque Vieira
More information about the openjfx-dev