There is already some documentation about this in the javadoc for Font.java:

 * <p>
 * The size of a {@code Font} is described as being specified in points
 * which are a real world measurement of approximately 1/72 inch.
 * <p>

and 

 * Note that the real world distances specified by the default coordinate
 * system only approximate point sizes as a rule of thumb and are typically
 * defaulted to screen pixels for most displays.

In other words, the DPI used to map point to pixel on the screen is 72.
So, 12 points equals 12 pixels.

It is different on the printer, where 72pt font should be exactly 1 inch on the 
paper.

The confusion happens because in CSS the DPI is 96.
So, the same 12pt set in CSS maps to a 16 pixel font on the screen.

Note that is behavior can not be changed.
At best, we can document a bit better on Font and/or CSS.

I hope this helps
Felipe


On Jan 16, 2014, at 1:35 AM, Alexander Kouznetsov 
<alexander.kouznet...@oracle.com> wrote:

> Tom,
> 
> Could you please file a bug on this?
> 
> Best regards,
> Alexander Kouznetsov
> (408) 276-0387
> 
> On 23 дек 2013 15:31, Tom Schindl wrote:
>> Hi,
>> 
>> The JavaDoc of Font.font says:
>> 
>> -----8<-----
>> size - The point size of the font. This can be a fractional value, but
>> must not be negative. If the size is < 0 the default size will be used.
>> -----8<-----
>> 
>> I highly doubt this is correct (see attached picture from Linux where
>> you see native, qt and javafx) and a sample FX-Code using setFont and
>> using CSS (see at the end of this mail)
>> 
>> The result is correct if CSS is used and looking up the code in the CSS
>> shows that values are calculated back to pixels when passed to the
>> Font-factory method (FontConverter.convert!).
>> 
>> I guess one can not fix this Font.font API to really work with points
>> (which would be the natural expectation at least to me) but the JavaDoc
>> has to be fixed!
>> 
>> Another thing I came across is that the DPI calculation is fixed to 96
>> DPI - which i don't fully understand why it is fixed because the DPI can
>> vary between devices and monitors. Is this because of multi-monitors and
>> you are applying a transformation based on the screen the text is
>> rendered on?
>> 
>> Tom
>> 
>> -----------
>>> HBox h = new HBox();
>>>             
>>>             {
>>>                     Text t = new Text("Hello World");
>>>                     t.setFont(Font.font(50));
>>>                     h.getChildren().add(t);                 
>>>             }
>>>             
>>>             {
>>>                     Text t = new Text("Hello World");
>>>                     t.setStyle("-fx-font-size: 50pt;");
>>>                     h.getChildren().add(t);                 
>>>             }
>>>             
>>>             primaryStage.setScene(new Scene(h,300,300));
>>>             primaryStage.show();
> 

Reply via email to