[Development] Why on Linux using FreeType engine fonts are rendered in 72 dpi instead of Screen DPI?

Jason H jhihn at gmx.com
Wed Oct 17 18:21:24 CEST 2018


A pixel is a pixel, regardless of DPI.

However things matter when you use point sizes (which assumes 72 points per inch) there are also Screen.devicePixelRatio  ( http://doc.qt.io/qt-5/qml-qtquick-window-screen.html#devicePixelRatio-attached-prop ) to contend with. I haven't had to worry about this for some time, so my intel may be out of date. It was a mess around 5.6...

I'm assuming the 72 has something to do with the point size, and being able to calculate scaling relative to 72. 


> Sent: Wednesday, October 17, 2018 at 11:59 AM
> From: "Tomasz Olszak" <olszak.tomasz at gmail.com>
> To: development at qt-project.org
> Subject: [Development] Why on Linux using FreeType engine fonts are rendered in 72 dpi instead of Screen DPI?
>
> Hi,
> 
> I would like just to ensure that I missed something and there is
> documentation somewhere informing that Linux fonts are rendered
> *always* in 72 dpi
> (https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Set_Char_Size)
> (which makes font.pixelSize inaccurate for regular screens).
> 
> I found: https://bugreports.qt.io/browse/QTBUG-8890 which fixes the
> problem but it was rejected. I see the default 72 dpi is also used in
> current Qt 5.11 FT engine
> (https://code.woboq.org/qt5/qtbase/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp.html#297).
> 
> Does it surprise any of Qt developers or is it only me? Am I right
> thinking that when we do following:
> Rectangle {
>    height: 100
>    Text {font.pixelSize: 100}
> }
> then the relation between height of text and height of rectangle will
> differ depending on screen dpi (don't have a way to test it
> currently)?
> 
> Moreover I'm pretty sure that's the cause I very often use
> Text.fontSizeMode: Text.Fit  because setting pixelSize to height of
> desired text size never worked correctly :)
> 
> tl;dr: Is it a bug?
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
> 



More information about the Development mailing list