Cross platform and font sizes
-
I'd like to hear your take on the issue. I have a fixed size window widget. Textual labels on it.
If on Mac, the label takes 50% of the width of my available space, in Ubuntu for instance, with the same text and font size, it would take 70% and on Windows, it's 35% This makes the width required for text labels unpredictable from platform to platform.
How do you deal with something like that?
-
Hi,
I'm interested to this method. Me too experienced the same problem. I used font size in point, to be sure that the size will be proportional and the same under ubuntu and windows, but this don't happens.
But I have also seen that is not clear how does works the font family specification.
-
It's a very interesting feature!!!
This has also the advantage that the same font can be ported on different platforms (almost desktop). If you have more info about this please tell me. Thanks.
-
I am finishing some other aspects of my code, but I will get to the font question very soon. Font wise, my app has to look identical as much as possible on OSX, Windows and Ubuntu. I have no intention of starting all kind of private cases in my code to support all of them individually. Gee, I hope it won't come to that anyway.
-
"QFontDatabase::addApplicationFont() ":http://doc.qt.nokia.com/latest/qfontdatabase.html#addApplicationFont can be your friend.
-
Thank you for the advise. I'm working too on these three platforms and should have the same fonts everywhere.
-
I know the thread is old, but I'd like to recommend for anyone who stumbles on this to use physical values (i.e. pt, in, mm, pc, etc) for your measurements, not pixel values. We can assume that most displays follow the VESA EDID standard, and we can rely on a point (pt) actually being 1/72 of an inch on the screen.
In Qt C++, you can use the "QScreen":http://qt-project.org/doc/qt-5/qscreen.html class to get all sorts of info regarding the screen including the dimensions of your screen in mm. In QML, the "Screen":http://qt-project.org/doc/qt-5/qml-qtquick-window-screen.html type is available with a similar subset of info. You can use this info to determine what type of device you are on and how your UI should react.
With this info, you can infer what size the device or viewing area of your app is. With this knowledge, you can decide whether to use measurements relative to the width of the viewing area, or physical values. For example, you might decide to set the base font size of your app to 16pt, or two 10% of the app width, then you can use relative values based on the base font size to render bigger or smaller fonts.