[Interest] Cross-platform font normalization best practice

René J.V. Bertin rjvbertin at gmail.com
Thu May 14 10:30:55 CEST 2015


On Thursday May 14 2015 12:06:51 Hamish Moffatt wrote:

>Alternatively, if you just want one font throughout, or mostly 
>throughout, you can set it as your default font with 
>QApplication::setFont(), then don't specify the font names at all in 
>your style sheets. This is what we're doing here, although we do use the 
>same font on both platforms.

I think the problem with that would be that you give up "WYSIWIG" while designing the .ui files, which could be an issue for the OP who seems to be concerned mostly with getting the layout just right.

If I were in such a situation I would probably just move the platform-specific code from the .ui files to the .pro (or CMake) files, and maintain different .ui files. If the various fonts used render sufficiently similar on your main dev platform, the .ui files for that platform are the masters, which you copy and then fine-tune for the other platforms you target. If not, you'll have to do the fine-tuning on the target platform.

Is this by any chance a case of purely replacing font names, i.e. something you could do in a script/parser that you invoke from your qmake or cmake file (i.e. through qmake or cmake)? If so, I'd go with that. It's probably the closest you can get to platform-specific code in .ui files, at the moment.

R.



More information about the Interest mailing list