I want to load hindi font form the resource. But whenever i tried use QFontDatabase::addApplicationFontFromData && addApplicationFont it returns -1 . Below is my code .
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
QFile res
("fonts/raghu.ttf");
if (res.
open(QIODevice::ReadOnly) == false) { qDebug()<<"error not able to load the file";
}
//File loaded sucessfully
qDebug()<<"File Information";
qDebug()<<"handle::"<<res.handle()<<"Size::"<<res.size()<<"\n";
//*QTextStream in(&res);
qDebug()<<res.readAll();
if (fontID == -1 ) {
qDebug()<<"error";
}
else
qDebug()<<fontID;
ui->setupUi(this);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QFile res("fonts/raghu.ttf");
if (res.open(QIODevice::ReadOnly) == false) {
qDebug()<<"error not able to load the file";
}
//File loaded sucessfully
qDebug()<<"File Information";
qDebug()<<"handle::"<<res.handle()<<"Size::"<<res.size()<<"\n";
//*QTextStream in(&res);
qDebug()<<res.readAll();
QByteArray data =res.readAll();
int fontID = QFontDatabase::addApplicationFontFromData( data );
if (fontID == -1 ) {
qDebug()<<"error";
}
else
qDebug()<<fontID;
ui->setupUi(this);
}
To copy to clipboard, switch view to plain text mode
Kindly guide me where i am doing wrong . Thank you
Bookmarks