Important: Please read the Qt Code of Conduct -

QFontMetrics.width() fails on a binary character

  • I sometimes would like to draw text that contains binary characters. I don't mind if the drawn character is some funny squiggle, all I want is for the character string to be displayed.

    The program used to work in the past, but since I installed the latest Qt version 5.12.2, it now issues an error on binary characters like the character \x01.

    The same error may arrive in various places in the program. For example, QFontMetrics.width("\x01") fails with this error message:

    DirectWrite: CreateFontFaceFromHDC() failed (Indicates an error in an input file such as a font file.) for QFontDef(Family="8514oem", pointsize=10, pixelsize=20, styleHint=5, weight=50, stretch=100, hintingPreference=0) LOGFONT("8514oem", lfWidth=0, lfHeight=-20) dpi=144

    If I try to continue execution after the error, the program crashes.

    The same program works perfectly well for all strings, as long as they don't include any binary characters.

    How can I return to the "old" days when binary characters were just equivalent to some squiggle character?

  • Lifetime Qt Champion


    Can you check with older versions of Qt to determine at which point the behaviour changed ?

  • @SGaist

    My previous version was 5.10, and I think that everything then worked correctly.
    I can't be sure that I tried to display at that time some binary characters, but I think it's very likely.

  • Lifetime Qt Champion

    Can you check that ? That would help hunting when exactly that issu started.

  • @SGaist

    Tracing that would require hours for re-installing Qt and recompiling the program, which I would prefer to avoid.

    Up till now, none of the bug reports I worked hard to report were ever treated, so I'm a bit wary of investing these hours.

  • Lifetime Qt Champion

    Do you have an example of such a report ?

Log in to reply