qt-webassembly-examples icon indicating copy to clipboard operation
qt-webassembly-examples copied to clipboard

How to change the font family

Open adjivas opened this issue 8 years ago • 2 comments

Hello,

It is possible to configure the font family?

For the sub-example gui_raster, I have naively tried to add a font according to the QFontDatabase Class without any success.

#include <QtGui>
#include <QFontDatabase>
#include <stdio.h>

#include "rasterwindow.h"

int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);
    QFontDatabase fontDB;

    int id = fontDB.addApplicationFont(":/fonts/Neko-SourceCodePro-Regular.ttf");
    printf("id: %d \n", id); // return  -1
    RasterWindow window;
    window.showFullScreen();
 
    return app.exec();
}

adjivas avatar Dec 10 '17 06:12 adjivas

Did you add the font file to the build? The default fonts are added in src/plugins/platforms/html5/fonts/html5fonts.qrc .

(We don't have direct access to the system font files)

msorvig avatar Jan 11 '18 11:01 msorvig

Is there an issue with fonts?! .. I tried out already shipped fonts in src/plugins/platforms/html5/fonts/html5fonts.qrc, they are not loaded (qtQuick)? (Vera.ttf , and DejaVuSans.ttf)

MohammadKanan avatar Sep 11 '18 16:09 MohammadKanan