Important: Please read the Qt Code of Conduct -

Qt 4 synthesizes Helvetica font on Windows?

  • When I build and run the following code with Qt 4.8 on Windows :
    #include <QApplication>
    #include <QFontDatabase>
    #include <QFontInfo>
    #include <QDebug>
    #include <QPainter>
    #include <QImage>

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    QFont f("Helvetica");
    QFontDatabase fdb;
    qDebug() << fdb.families().indexOf("Helvetica");
    QImage image(100,100,QImage::Format_ARGB32);
    QPainter painter(&image);
    qDebug() << fdb.families().indexOf("Helvetica");
    qDebug() << fdb.isSmoothlyScalable("Helvetica") << QFontInfo(f).exactMatch() << QFontInfo(f).family();

    return 0;


    It shows this output:
    true true "Helvetica"

    It indicates that the font "Helvetica" was not available as exact match before I draw some text using it.

    With Qt 5.3:
    false false "Arial"

    which is what I expect.

    Is there any way to stop Qt 4 from "synthesizing" a Helvetica font? It doesn't do this with any other fonts I tried.

Log in to reply