CSS Font size in points doesn't match Node.Font.Size
philip.race at oracle.com
Thu Mar 6 13:10:51 PST 2014
> Our CSS implementation will convert -fx-font-size: 12pt; to 9px
> since CSS says that 72/96th of a point equals a pixel
I think your sum is backward. If 0.75pts==1 pixel then a 12 pt font will
be 16 pixels.
Perhaps another way of looking at this is that the CSS "1 pixel=1/96
shouldn't be taken as applying to FX since it has its own approximation
that 1 pixel=1/72 inch.
In the two year ago discussion I think the central point was that
is wholly ignorant of the actual screen DPI and it always interprets as
"user space" pixels which are equated to points. There is definitely no
starting point (ahem) of trying to do any mapping to the real world sizes.
Printing applies a transform from user-space to device space because
the approximation of 72dpi would not be at all satisfactory there.
And since we do that and we have good information on the real DPI
of the device, we can get it "exactly right".
On screen nothing of the kind will happen unless you figure
something out and directly apply it to your entire Scene.
On 3/6/2014 11:37 AM, David Grieve wrote:
> Hey Felipe,
> I recall a couple of years ago when Phil drilled it into me that Font
> size was pixels. So when you said that Font size is point, I was
> skeptical. But, indeed, you are correct and I am mistaken.
> I see now that setting font size from point units in our CSS is
> broken. Our CSS implementation will convert -fx-font-size: 12pt; to
> 9px since CSS says that 72/96th of a point equals a pixel. But that
> should convert to 12px. Fortunately, modena and caspian are all pixel
> based units.
> It is important to note that if the assertion that DPI=72 ever
> changes, then CSS will be broken since I've (incorrectly) assumed all
> along that Font size is pixels.
> On 3/6/14, 1:47 PM, Felipe Heidrich wrote:
>> On Mar 5, 2014, at 3:18 PM, Tom Schindl <tom.schindl at bestsolution.at>
>>> Why can't JavaFX not at least provide a font-API to create fonts
>>> with point?
>> The current JavaFX API is point (see the doc).
>> The thing is, on the desktop it uses DPI=72, so px=pt.
>> In the printer the actual device DPI is used (so that 72pt=1in on the
>> Note, Mac is exactly the same, see the doc for CTFontRef for example
>> It talks about point size the very same way JavaFX does.
>> That is so true that the very value passed to Font.font(double) is
>> passed to CTFontCreateWithName() in CTFontStrike.java as is.
>> The same is true for Windows, using DirectWrite and Linux, using
More information about the openjfx-dev