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

Allan Sandfeld Jensen kde at carewolf.com
Wed Oct 17 19:07:36 CEST 2018


Hi 

That is a incorrect assesment. Fonts are rendered in pixel sizes. When you 
request a QFont at a certain pixel size you get the font in that size. It 
should be noted that those sizes ONLY matter for things like pixel hinting.
The font will typically be rendered in the same size it was requested, but in 
some cases a specific font-size is used at a different resolution (for 
instance with hidpi modes), in that case pixel-hinting is disable, and we do 
vector based rendering of the glyphs.

In any case the DPI is irrelevant and only matters if you select fonts by 
point instead of pixels, and then the translation to pixels is done before we 
get anywhere near the font engine.

'Allan

On Mittwoch, 17. Oktober 2018 17:59:26 CEST Tomasz Olszak wrote:
> 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#F
> T_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/freetyp
> e/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