[Interest] Achieving resolution independent font sizes with Qt

Thiago Macieira thiago.macieira at intel.com
Fri Jun 7 17:25:48 CEST 2013


On sexta-feira, 7 de junho de 2013 16.57.20, Nikos Chantziaras wrote:
> Is there an approach I can take to make the font sizes in applications
> independent of the current resolution?  For example, let's say I choose
> a font with a 12pt size, meaning setting it with
> QFont::setPointSize(10).  If the font is displayed while the monitor's
> resolution is 1920x1080, the font is rather small.  Now if I quit the
> application, switch the monitor to 640x480 (scaling-up but preserving
> the aspect ratio), the font is quite big.  As a side effect of this,
> even if my application is going fullscreen and always using a display
> area of a 4:3 ratio, only about half the text fits when the resolution
> is 640x480.
> 
> What would be a good way of making sure that a font looks the same size
> on screen regardless of resolution?  I'm on Linux, but I'm hoping
> there's a portable way to achieve that.

Hi Nikos

There's something wrong with your setup. Font sizes *are* resolution 
independent. The definition of "point" is that 72 pt = 1 inch of actual screen 
size.

Now, most display systems will not update the screen DPI when changing 
resolutions. That is a known issue and please don't expect any changes 
anywhere. The question is simply: does the font size look right in the default 
resolution of your setup?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130607/8182bd8f/attachment.sig>


More information about the Interest mailing list