Mac: mini font

On Mac you can often see the usage of two system fonts in applications. Second one “Mini” is convenient to use when you would like to have a lot of “mini” controls – mostly you can get it by applying Qt::WA_MacMiniSize. Well then the font is coming from mac style, but what if the font is needed as QFont object?

#ifdef Q_WS_MAC
    #include <Carbon/Carbon.h>
    //need a method from qglobal.cpp
    extern QString qt_mac_from_pascal_string(const Str255);
#endif

...

QFont systemMiniFont()
{
#ifdef Q_WS_MAC
    Str255 f_name;
    SInt16 f_size;
    Style f_style;    
    static const ScriptCode Script = smRoman;
    
    GetThemeFont(kThemeSmallSystemFont, Script, 
                 f_name, &f_size, &f_style);
    
    QFont font(qt_mac_from_pascal_string(f_name), f_size, 
               (f_style & ::bold) ? QFont::Bold : QFont::Normal,
               (bool)(f_style & ::italic));
    
    return font;
#endif
    return qApp->font();
}
This entry was posted in Blog, Qt. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>