Results 1 to 4 of 4

Thread: Retrieve the filename of a QFont

  1. #1
    Join Date
    Jun 2009
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default Retrieve the filename of a QFont

    Hi,

    I am doing an exporter of ttf files to our internal engine format. I am using a QFontComboBox to let the graphics choose the font he want convert and do a simple preview with a QTextEdit.

    I am using Freetype to do the conversion, that why I try to use the QFont::freetypeFace method, but it doesn't work on Windows.

    For the moment I build the file name with the font family name, but it doesn't work for all fonts.

    It might possible to load all fonts of the C:/Windows/Fonts with freetype and check if one have the same family name, but this solution is dirty and slow.

    Edit :
    Some ttf files contains only one face, that why some font are in many tff files (i.e. arial.ttf for "Arial Regular", ariali.ttf for "Arial Italic", etc.).
    The problem is ttf files don't have any convention on the file name format.

    I also need to be able to get the right file with font style (bold, italic,...).

    Can I find some information in the register base of Windows for making the relation between the font and the file name?
    Last edited by flamaros; 31st December 2009 at 15:52. Reason: Add some informations
    Koalabs Studio

  2. #2
    Join Date
    Jun 2009
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Retrieve the filename of a QFont

    I finaly scan this table from the register table :
    HKLM\Software\Microsoft\Windows\CurrentVersion\Fon ts
    Koalabs Studio

  3. #3
    Join Date
    Mar 2009
    Posts
    14
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Retrieve the filename of a QFont

    Qt Code:
    1. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
    To copy to clipboard, switch view to plain text mode 
    I find it in windows xp

  4. #4
    Join Date
    Mar 2009
    Posts
    14
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Retrieve the filename of a QFont

    Qt Code:
    1. QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
    2. QSettings::NativeFormat);
    3. QStringList list = settings.allKeys();
    4.  
    5. for(int i=0;i<list.size();i++)
    6. {
    7. QString key = list.at(i);
    8. QString text = settings.value(key).toString();
    9. QStringList keys = key.split(" & ");
    10. QString last = keys.last();
    11. keys[keys.size()-1] = last.left(last.indexOf(" ("));
    12. for(int j=0;j<keys.size();j++)
    13. {
    14. index.insert(keys[j], j);
    15. name.insert(keys[j], text);
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    you can use it as
    Qt Code:
    1. QString family = ui->fontComboBox->currentText();
    2. QString path("C:/WINDOWS/Fonts/");
    3. path.append(name[family]);
    4. int in = index[family];
    5. FT_New_Face(library, path.toUtf8(), in, &face)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Finding filename from QNetworkReply
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2009, 10:29

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.