[Interest] Qt5 font size issue with fontconfig

Ramakanth Kesireddy rama.kesi at gmail.com
Wed Nov 11 06:23:12 CET 2020


Hello Thiago,

In our application, based on DPI 141(screen size: 5.7" 480X640), the
application font is set as 7pt based on the below calculation where px is
14 to look the font normal.

double pxToPt(double px, double dpi) {
    return px*72/dpi
}

but the font size on target is small even though we set QCoreApplication::
setAttribute(Qt::AA_EnableHighDpiScaling);

So if we use default font to retrieve the default font point size, it shows
as 12pt which looks font size normal on display.
QFont f;
int defaultFontSize = f.pointSize();

Question is if we need to use default font point size for the current
reference DPI display and set QCoreApplication::setAttribute(Qt::
AA_EnableHighDpiScaling)
so that it scales for the 8" or 10" display? Though we need to convert
existing pixel size to point sizes in the application code and use layouts
in some parts of code instead of setting fixed width or any hardcoded
values.

Incase we need to show larger font, do we need to increment 4pt from the
reference 12pt incase it is correct?

Appreciate for your feedback in this regard.

Best Regards,
Ramakanth

On Sun, 8 Nov, 2020, 21:30 Thiago Macieira, <thiago.macieira at intel.com>
wrote:

> On Saturday, 7 November 2020 00:28:50 PST Ramakanth Kesireddy wrote:
> > Ok Thanks for your mail. Forgot to mention that Qt UI is based on
> > QWidgets(QPainter) with unicodes.
> >
> > Is this the reason why auto scale attribute doesn't works and need to use
> > QFontmetrics to set point size for the DPI accordingly?
>
> I do not understand you.
>
> What isn't working properly? Please describe without comparing to Qt 4.
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel DPG Cloud Engineering
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20201111/52ebb901/attachment.html>


More information about the Interest mailing list