Re: Font.font() says it is point size but it looks like it are pixels
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();
Font.font() says it is point size but it looks like it are pixels
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();