diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-06-04 12:47:22 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-06-10 11:13:11 (GMT) |
commit | ae9cc6c29521f1b597c3120f638d125892cdd593 (patch) | |
tree | 24992ca1539efdb1c6fd0c4752d4de3f153d5b68 /tests | |
parent | f541c78e1bc5b293466b40e6f10496199a4a5d73 (diff) | |
download | Qt-ae9cc6c29521f1b597c3120f638d125892cdd593.zip Qt-ae9cc6c29521f1b597c3120f638d125892cdd593.tar.gz Qt-ae9cc6c29521f1b597c3120f638d125892cdd593.tar.bz2 |
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: http://codereview.qt.nokia.com/333
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
(cherry picked from commit 97391be5ebddc62545ddb88f92fc2045bfa10711)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qfont/tst_qfont.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qfont/tst_qfont.cpp b/tests/auto/qfont/tst_qfont.cpp index cfafa78..711ffc0 100644 --- a/tests/auto/qfont/tst_qfont.cpp +++ b/tests/auto/qfont/tst_qfont.cpp @@ -77,6 +77,7 @@ private slots: void insertAndRemoveSubstitutions(); void serializeSpacing(); void lastResortFont(); + void styleName(); }; // Testing get/set functions @@ -612,5 +613,17 @@ void tst_QFont::lastResortFont() QVERIFY(!font.lastResortFont().isEmpty()); } +void tst_QFont::styleName() +{ +#if !defined(Q_WS_MAC) + QSKIP("Only tested on Mac", SkipAll); +#else + QFont font("Helvetica Neue"); + font.setStyleName("UltraLight"); + + QCOMPARE(QFontInfo(font).styleName(), QString("UltraLight")); +#endif +} + QTEST_MAIN(tst_QFont) #include "tst_qfont.moc" |