diff options
author | Alessandro Portale <alessandro.portale@nokia.com> | 2010-09-28 14:57:20 (GMT) |
---|---|---|
committer | Alessandro Portale <alessandro.portale@nokia.com> | 2010-09-28 14:57:20 (GMT) |
commit | c4ef479906f073fa84999eb950f00e264ebd4e8e (patch) | |
tree | bac14192b21cb3c533961dda3abc42f6e5b94fc7 /src/gui/text | |
parent | 1341477e03dae2f9bc5ddb25beeb2ba3cd23358f (diff) | |
download | Qt-c4ef479906f073fa84999eb950f00e264ebd4e8e.zip Qt-c4ef479906f073fa84999eb950f00e264ebd4e8e.tar.gz Qt-c4ef479906f073fa84999eb950f00e264ebd4e8e.tar.bz2 |
Fix QFontMetrics::lineWidth() for fonts with defined point size
QFontMetrics::lineWidth() and ::underlinePos() return value 1
regardless of the font size if the size was defined in points
(instead of pixels).
(On Symbian) QFontMetrics::lineWidth() calls
QFontEngine::lineThickness() which uses its fontDef.pixelSize in
order to come up with a suitable line width. If the QFont size
was defined in points, Qt needs to make sure that fontDef.pixelSize
is set accordingly. This patch adds the code to make sure that
QFontEngine::fontDef always has a valid pixel size.
tst_QFontMetrics::lineWidth() was added, wich failed before and
passes after this patch.
Task-Number: QTBUG-13009
Autotest: Passes
Reviewed-By: Eskil
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase_s60.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index ec252cd..5e168c6 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -453,7 +453,7 @@ QFontDef cleanedFontDef(const QFontDef &req) return result; } -QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *, const QFontDef &req) +QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *d, const QFontDef &req) { const QFontCache::Key key(cleanedFontDef(req), script); @@ -498,8 +498,14 @@ QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *, const QFo static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(fontFamily, request.weight > QFont::Normal, request.style != QFont::StyleNormal); + + // We need a valid pixelSize, e.g. for lineThickness() + if (request.pixelSize < 0) + request.pixelSize = request.pointSize * d->dpi / 72; + fe = new QFontEngineS60(request, typeFaceExtras); #else // QT_NO_FREETYPE + Q_UNUSED(d) QFontEngine::FaceId faceId; const QtFontFamily * const reqQtFontFamily = db->family(fontFamily); faceId.filename = reqQtFontFamily->fontFilename; |