Results 1 to 3 of 3

Thread: QFontDatabase::addApplicationFont works in Embedded Linux, but not in Linux Ubuntu

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QFontDatabase::addApplicationFont works in Embedded Linux, but not in Linux Ubuntu

    Hi!

    I have an app developed with Qt 4.8 compiled for both Embedded Linux Arm as well as Linux Ubuntu. It uses a specific set of fonts which I need to have installed for it to run, something I do with QFontDatabase::addApplicationFont. Everything works fine when I compile for Embedded Linux, but when I do it for Linux Ubuntu, I got -1 and the fonts are not loaded.

    I tried to find on the web a solution for the problem but I found no help. Similar problems were solved by updating Qt 4.6 to 4.7 (nothing of use) or by installing fontconfig, which I already have. Also I couldn't find anything useful in Qt Assistant and checked the paths to the .ttf files.

    Any help will be appreciated.

    Here is the code I'm using:

    Qt Code:
    1. QFontDatabase::removeAllApplicationFonts();
    2.  
    3. QDir fontDir(DEFAULT_FONTS_PATH);
    4. QStringList fontFileList = fontDir.entryList(QStringList("*.ttf"), QDir::Files | QDir::NoDotDot | QDir::NoDot);
    5.  
    6. mDebugS(QString("Found %1 fonts on folder theme/fonts").arg(fontFileList.size()));
    7.  
    8. //
    9. qint32 fontId;
    10.  
    11. foreach (const QString& filename, fontFileList)
    12. {
    13. fontId = QFontDatabase::addApplicationFont(DEFAULT_FONTS_PATH "/" + filename);
    14.  
    15. if (Q_UNLIKELY(fontId == -1))
    16. {
    17. const QString strTemp = QString("Unable to install font %1").arg(filename);
    18.  
    19. mLog(strTemp);
    20. mDebugS(strTemp);
    21. }
    22. else
    23. applicationFontsIdList.append(fontId);
    24. }
    25.  
    26. mDebugS(QString::number(applicationFontsIdList.size()) + " fonts are installed");
    To copy to clipboard, switch view to plain text mode 

    Note: the same question was put in StackOverflow (link)
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFontDatabase::addApplicationFont works in Embedded Linux, but not in Linux Ubunt

    Making the thread go up!
    May the Lord be with you. Always.

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFontDatabase::addApplicationFont works in Embedded Linux, but not in Linux Ubunt

    Going up once again!
    May the Lord be with you. Always.

Similar Threads

  1. Replies: 15
    Last Post: 9th November 2012, 20:07
  2. Replies: 5
    Last Post: 21st June 2012, 00:40
  3. Replies: 5
    Last Post: 25th April 2012, 12:34
  4. Replies: 3
    Last Post: 6th August 2011, 00:19
  5. Build QT Embedded Linux Ubuntu Error ?
    By Thành Viên Mới in forum Installation and Deployment
    Replies: 0
    Last Post: 4th November 2010, 05:15

Tags for this Thread

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.