Results 1 to 6 of 6

Thread: QFontDatabase::addApplicationFontFromData && addApplicationFont returns -1

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QFontDatabase::addApplicationFontFromData && addApplicationFont returns -1

    I want to load hindi font form the resource. But whenever i tried use QFontDatabase::addApplicationFontFromData && addApplicationFont it returns -1 . Below is my code .

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. QFile res("fonts/raghu.ttf");
    6.  
    7. if (res.open(QIODevice::ReadOnly) == false) {
    8. qDebug()<<"error not able to load the file";
    9.  
    10. }
    11.  
    12. //File loaded sucessfully
    13. qDebug()<<"File Information";
    14. qDebug()<<"handle::"<<res.handle()<<"Size::"<<res.size()<<"\n";
    15.  
    16. //*QTextStream in(&res);
    17. qDebug()<<res.readAll();
    18.  
    19. QByteArray data =res.readAll();
    20.  
    21. int fontID = QFontDatabase::addApplicationFontFromData( data );
    22.  
    23. if (fontID == -1 ) {
    24. qDebug()<<"error";
    25. }
    26. else
    27. qDebug()<<fontID;
    28.  
    29. ui->setupUi(this);
    30. }
    To copy to clipboard, switch view to plain text mode 

    Kindly guide me where i am doing wrong . Thank you
    Last edited by Lykurg; 22nd December 2010 at 10:40. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.