PDA

View Full Version : QFontDatabase loading font from resource



myrky
27th May 2010, 13:28
Hi,
I want to load a font from the resource using QFontDatabase but it don't work. Here the code that i use :



QFontDatabase fontDB;
fontDB.addApplicationFont(":/GraphicsView/fonts");

foreach(QString s, fontDB.families())
{
qDebug() << s;
}


Am i doing something wrong or it's impossible to load font from the resource ?

tbscope
27th May 2010, 13:45
fontDB.addApplicationFont(":/GraphicsView/fonts");



Is this actually a font called "fonts" ?

myrky
27th May 2010, 13:50
no it's the folder where i put all the font, i just found that i needed to specify the file name also.

this solve my problem :


fontDB.addApplicationFont(":/GraphicsView/fonts/font.ttf");

Thank you for your help