path: root/src/gui/text/qfont.h
diff options
authorJiang Jiang <>2011-06-04 14:47:22 +0200
committerQt Continuous Integration System <>2011-06-09 15:07:13 +0200
commit97391be5ebddc62545ddb88f92fc2045bfa10711 (patch)
tree0f7e7252a8e41d0c9a00f348dcfff2ff25666bef /src/gui/text/qfont.h
parentb97215b04c0bf12ecfd51ccdeaedd1fab5e8bc03 (diff)
Allow selecting fonts with irregular style names
Fonts like "Helvetica Neue UltraLight" or "Skia Regular Black Condensed" can't be selected in Qt because either they don't report correct numeric values for weight/stretch/etc. or these values are not mapped from QFont enums in a linear way. Thus we provide a shortcut to select these fonts with PostScript name or full name without resorting to family name matching in QFontDatabase (these fonts are not registered in font database anyway). After this, we can simply use: QFont font("Helvetica Neue"); font.setStyleName("UltraLight"); to select these fonts. QCoreTextFontEngineMulti matched like this can be created directly from the CTFontRef instance instead of creating from the font name, making this process faster. The commit also cleaned up the font loading process in Mac font database a bit, moving the code for family matching into a separate function. Add QFontInfo::styleName() and QRawFont::styleName() to access the resolved style name for a font. Task-number: QTBUG-19366 Change-Id: Iad07768c02ed06cc8d6b7395dec554384f410506 Reviewed-on: Reviewed-by: Qt Sanity Bot <> Reviewed-by: Jiang Jiang <>
Diffstat (limited to 'src/gui/text/qfont.h')
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 7636ecf910..14f290ceb3 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -156,7 +156,8 @@ public:
LetterSpacingResolved = 0x2000,
WordSpacingResolved = 0x4000,
HintingPreferenceResolved = 0x8000,
- AllPropertiesResolved = 0xffff
+ StyleNameResolved = 0x10000,
+ AllPropertiesResolved = 0x1ffff
@@ -168,6 +169,9 @@ public:
QString family() const;
void setFamily(const QString &);
+ QString styleName() const;
+ void setStyleName(const QString &);
int pointSize() const;
void setPointSize(int);
qreal pointSizeF() const;