PDA

View Full Version : addApplicationFont() doesn't work for all fonts



chritz
8th August 2011, 10:10
Hello,

I'm having problems using chinese .ttf font (on Symbian Device using Qt4.7.3, Nokia N8) As I didn't get any solving answers in the newbie forum, maybe you can help me?

When I load a "standard" font like Arial, it works. Loading a Chinese Font doesn't work.


MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::ExistingFile);
QString fileName;
fileName = dialog.getOpenFileName(this);
qDebug()<<QFontDatabase::addApplicationFont(fileName);
//qDebug displays 0 for Arial.ttf, but -1 for chinese.ttf (not the real font Name)
bool ok;
QApplication::setFont(QFontDialog::getFont(&ok,this));
//**see below
ui->setupUi(this);
}

**As a consequence the font Dialog has Arial in its font list and returns true when selecting it, but not the chinese one.

-The fonts are located in the same directory.
-I got both fonts from the Windows Font Directory
-I tried 3 different chinese fonts, so I don't think the problem is related to a damaged font file.

I just found similar threads about addApplicationFont not working at all. But as it works for some fonts I don't know what I did wrong.

Thanks,
Chris