Font Rendering Problem

  • ! glyph)!

    There seems to be a problem illustrated by the problem glyph picture with font rendering on the Qt Embedded Linux platform. I haven't tested it on other platforms.

    The picture illustrates an antialiasing problem specific to Qt. Notice that the grays around the i in "is" are 2 pixels wide on the right side. This looks bad. My first thought was that the font needed hinting, but I'm not so sure now for the following reasons. Please excuse and/or correct any lack of accuracy in my description of font rendering.

    I would expect that antialiasing should be at most 1 pixel wide. For example if the black span only partially covers a pixel, that pixel is something less than 100% opaque, but only that pixel, not the right-adjacent pixel.

    When I use the font with other rendering engines (freetype, Microsoft Word, etc.) I don't see the problem. The gray is 1 pixel wide on the right side of the i glyph at the same family/size/platform when using freetype to render directly.

    I did a little digging in the Qt source. The following code looks suspicious to me.

    @QFixed QFontEngine::lineThickness() const
    // ad hoc algorithm
    int score = fontDef.weight * fontDef.pixelSize;
    int lw = score / 700;

    // looks better with thicker line for small pointsizes
    if (lw < 2 && score >= 1050) lw = 2;
    if (lw == 0) lw = 1;
    return lw;



    QFontEngine::lineThickness() is called by QFontEngine::properties().

    When I comment out the following line, it fixes the problem glyph, but I'm afraid of regression issues (haven't tested to check yet).

    @ if (lw < 2 && score >= 1050) lw = 2;

    I would appreciate it if someone more familiar with Qt font rendering would validate this problem and offer safe recommendations for a work-around/fix (other than to forgo using QPainter::drawText() and use freetype directly).


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.