Qt Embedded Font rendered as squares
-
Hi all !
I've been developping using Qt 2.3 for a very long time and now as I switched
to Qt 4.7, I have a small problem regarding to font rendering. I compiled Qt with
the -prefix /usr option and, in the final target FS image, libraries are in /usr/lib
and fonts are all in /usr/lib/fonts.I tried to compile the mousecalibration example and everything went fine until I
wanted to launch the app: characters where rendered as squares. So I added
a few lines of code to display what was happening:First of all I specified a default font (helvetica_120_50.qpf is present).
@ QApplication::setFont(QFont("helvetica", 12));@
Then I listed all the fonts available:
@
{
QFontDatabase *fdb = new QFontDatabase ;
QStringList fam = fdb->families();qDebug() << "QFontDatabase::Any: available font families -> " << fam.count(); for (int i = 0 ; i < fam.count() ; i++) { qDebug() << fam[i]; } }
@
Here is the output:
QFontDatabase::Any: available font families -> 1
"helvetica"
.When I add more qpf fonts, they are all listed. However no TTF font
(such as DejaVuSans) are listed... Not only that, but even specifying
helvetica, which is a known font to the system, characters are still
rendered as squares.After that I tried to explicitly load the DejaVuSans font:
@
int id = fdb->addApplicationFont("/usr/lib/fonts/DejaVuSans.ttf");
qDebug() << "Loaded ttf font: " << id;
@But the result was: "Loaded ttf font: -1"
Does anyone know what I'm missing here ?
-
http://qt-project.org/doc/qt-4.8/qfontdatabase.html#addApplicationFont
maybe this will be helpfull, doеs your system have fontconfig?
Have you tried to addFromData ? -
[quote author="Xooch" date="1415895249"]Did you ever resolve this issue? I have a similar problem, but with Qt 5.3.[/quote]
This was discussed in other thread, see if this helps? "Link to other thread":http://qt-project.org/forums/viewthread/8331/
-
[quote author="Xooch" date="1415895249"]Did you ever resolve this issue? I have a similar problem, but with Qt 5.3.[/quote]
This was discussed in other thread, see if this helps? "Link to other thread":http://qt-project.org/forums/viewthread/8331/