Results 1 to 3 of 3

Thread: How to handle cross platform font sizes

  1. #1
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to handle cross platform font sizes

    After developing my app on windows I have recently started to look at it on mac and I have encountered what must be a very common problem with font sizes.

    When I have used a QLabel for header text I have set the font-size on windows to be bigger, because qt doesn't support (that I know of) the concept of setting the size to "larger" I have set a pt value. But this messes up the text on mac actually making it smaller then standard text because it uses a different font all together and the sizes are very different.

    So what is the best way of specifying a QLabel to be essentially a header?

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to handle cross platform font sizes

    The size difference is more likely due to different screen resolutions. In any case, when your program starts up you can obtain the screen DPI, then iterate over a range of font sizes until you find one that renders a given string to a length of, say, one inch. The point size may differ from font to font and from platform to platform, but the rendered size will be approximately the same across all systems.

    You can never do better than an approximation, though. Other factors, like the font rendering engine, particular font involved, kerning settings and more will cause even identically named and sized fonts to render differently on different platforms. You can, however, get "close enough" using an approach like that outlined above.

  3. #3
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to handle cross platform font sizes

    Hmmm that may be a bit overkill I don't really care how big the text renders on the screen. I think it's safe to assume that a platform's default font is legible, all I want to do is to make "header" labels use a bigger font size ( like 125% of the size ) regardless of what font is being used I know I can do this programmatically but that's a pain and then what you see in the designer isn't what you get.

    Is there a syntax via style sheets for font-size: larger or something similar to what you can do in html?

Similar Threads

  1. Replies: 1
    Last Post: 11th November 2010, 01:31
  2. Cross-platform GUI app
    By rockballad in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2010, 08:38
  3. QDialog Font sizes
    By cnbp173 in forum Qt Programming
    Replies: 0
    Last Post: 1st April 2009, 02:57
  4. Font sizes
    By StevenB in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2007, 11:10
  5. qt-config and font sizes
    By hvengel in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2007, 01:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.