[Interest] Cross-platform font normalization best practice
Bob Hood
bhood2 at comcast.net
Wed May 13 14:06:30 CEST 2015
On 5/13/2015 1:07 AM, Till Oliver Knoll wrote:
>> Am 12.05.2015 um 18:00 schrieb Bob Hood <bhood2 at comcast.net>:
>>
>> I see that on Windows, Designer defaults to the "MS Shell Dialog 2" 8-point
>> font, and on OS X (Yosemite) it is ".Helvetical Neue DeskInterface" 13-point
>> (in one field, while another oddly reports an "Al Bayan" typeface). I have
>> found that changing the OS X interface to use "Lucida Grande" 11-point instead
>> of ".Helvetical Neue DeskInterface" 13-point makes it very close to the
>> Windows font appearance.
> Now if I understand your need correctly you want the same font be used across all platforms, to have the same appearance (even if that brakes with font conventions on a specific platform), is that correct?
No, not really. I want to use the font/point sizes per platform that get each
platform to look as close to the same as possible. The normalization is for
the appearance, not the actual font itself.
So, to make OS X look close to the Windows default settings, I have to use a
font and/or size that is different than the OS X default settings. This
entails manually changing at runtime. I was wondering if there was a built-in
mechanism for handling that.
Adding a platform-specific section to the MainWindow constructor, just
following the setupUi() call, appears to achieve what I'm after:
ui->setupUi(this);
#ifdef _MACOS
// this normalizes the appearance of the dialog to look more like Windows.
this->setStyleSheet("font: 11pt \"Lucida Grande\";");
ui->label_Intro_Line_1->setStyleSheet("font: 18pt \"Tahoma\";");
ui->label_Intro_Line_2->setStyleSheet("font: 18pt \"Tahoma\";");
#endif
But it just feels clunky to me, since changes to the default Windows settings
in the *.ui file will require modification of the separate C++ code to match.
Having platform-specific sections in the *.ui file itself would seem to be a
more elegant approach.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150513/59986fce/attachment.html>
More information about the Interest
mailing list