qt-webassembly-examples
qt-webassembly-examples copied to clipboard
How to change the font family
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();
}
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)
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)