Allow selecting fonts with irregular style names
authorJiang Jiang <jiang.jiang@nokia.com>
Sat, 4 Jun 2011 12:47:22 +0000 (14:47 +0200)
committerQt Continuous Integration System <qt-info@nokia.com>
Thu, 9 Jun 2011 13:07:13 +0000 (15:07 +0200)
commit97391be5ebddc62545ddb88f92fc2045bfa10711
tree0f7e7252a8e41d0c9a00f348dcfff2ff25666bef
parentb97215b04c0bf12ecfd51ccdeaedd1fab5e8bc03
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>
12 files changed:
src/gui/text/qfont.cpp
src/gui/text/qfont.h
src/gui/text/qfont_p.h
src/gui/text/qfontdatabase_mac.cpp
src/gui/text/qfontdatabase_x11.cpp
src/gui/text/qfontengine_coretext.mm
src/gui/text/qfontengine_coretext_p.h
src/gui/text/qfontengine_ft.cpp
src/gui/text/qfontinfo.h
src/gui/text/qrawfont.cpp
src/gui/text/qrawfont.h
tests/auto/qfont/tst_qfont.cpp