Different OS's, different font sizes?
Maybe this is naive of me, but is it expected for fonts to render much smaller on OSX than on Windows?
I have a QML application that runs on both Windows (7) and OSX (10.8). I'm using the same font on both (literally the same font - they're exactly the same ttf files - installed on both Windows and OSX). When I run the application with the same QML files specifying the same point sizes, the letters are noticeably smaller on OSX than on Windows - its really easy to see because I can compare them to the size of adjacent bitmaps in the QML screen.
Is this expected? Is there any kind of a workaround that I could employ that wouldn't involve having separate QML files for OSX and Windows?
Yes, I am being naive. It turns out that "this is a very well known problem when specifying point sizes on a Mac vs Windows.":http://www.rfwilmut.clara.net/about/fonts.html. OSX has a display density of 72 points per inch, and Windows is 96 ppi.
Can Qt be set to use one dpi system or the other when specifying point sizes? IE could I use 96ppi point sizes with Qt on OSX or 72ppi point sizes with Qt on Windows?
I need to have a consistent layout and this font point size issue is throwing a spanner into the works. I don't want to have to add #ifdef QT_OS_MAC and #ifdef QT_OS_WIN32 all over the place and duplicate all of my qml files just to get a consistent layout on the two platforms.
I've found a couple of stack overflow questions with others struggling with this issue with Qt.
The one suggestion of having having percentage sizes (90% or whatever) seems like such a good idea. Its a shame that Qt doesn't seem to have any way of dealing with this?
It's interesting that the documentation for the QML Text object says this:
It actually seems like in my case, I'd be much better off doing it the other way around - that in this case pixel size will be less device-dependent than point size?
Point sizes are device-independent. A 16pt font should theoretically be the same size no matter what device you're on or what the density of the screen is, assuming that the vendor of the display follows "VESA standards":http://en.wikipedia.org/wiki/Extended_display_identification_data.
@font.pixelSize: parent.width * 0.9@
That's 90% of the parent.width. Figure out what you want 90% of, then multiply by 0.9. ;)