How to detect missing font characters

Is there a way to detect that all characters are displayed correctly with the current font? In some environments and fonts, some characters are replaced by a square character.

I would like to automatically check that all characters used in the GUI are supported by the current font.

+5
source share
3 answers

I found a possible solution using the QFontMetrics class . Here is an example function to query if all characters in the current QLabel text are available:

bool charactersMissing(const QLabel& label) {
    QFontMetrics metrics(label.font());
    for (int i = 0; i < label.text().size(); ++i) {
        if (!metrics.inFont(label.text().at(i))) {
            return true;
        }
    }
    return false;
}

Of course, displaying to a user who is absent will be good, but of course it needs to be done with a different font :)

+2

, QFontMetrics . https://bugreports.qt-project.org/browse/QTBUG-1732

QFontMetrics inFont() QFont, StyleStrategy QFont:: NoFontMerging. NoFontMerging , , inFont true, .

, python.

https://github.com/diro/pyGlyphChecker

+1

...


: ( ):

  • , , .

  • , FONT u, .

  • - Select OK (if he / she can read the text, ie only if there are no "squares")

    - Choose another FONT (if any "squares" are visible)

NOTE. . If you're interested, this is not a very unusual behavior for applications. MS-WORD does this when it detects non-standard encoding in a doc file.

GOODLUCK !!

0
source

All Articles