path: root/src/gui/text/qfontengine_ft.cpp
diff options
authorBernd Weimer <>2014-02-19 18:00:24 +0100
committerThe Qt Project <>2014-02-20 20:13:27 +0100
commitd641792ff29cae3ef92bbc76f593e9262b4789ef (patch)
tree9bfe649d393135bada63352d88a247a8e8b539aa /src/gui/text/qfontengine_ft.cpp
parent2d22e737757c959fff103a4a99fbd896ef09597b (diff)
Fix QFontMetrics width
Commit f4dd534 introduced a regression, so that QFontMetrics reported a wrong size (to be more specific width) for FreeType fonts. The calculation of glyph advances has to to reflect (rounded) integral number of pixels. This was only done when the glyph was cached. So in some cases the first call to QFontMetrics::size gave a different result than the second. This patch reverts f4dd5344fbbce257a40e014acc4e87f4773f40. The tst_QFontMetrics::same auto test only happened to work on some platforms, on BlackBerry for instance it did not. Extended the test case to make sure it works for different font sizes. Change-Id: Ia5bb9abd3ff98193c9bba048b85207672ed8d9c3 Reviewed-by: Konstantin Ritt <>
Diffstat (limited to 'src/gui/text/qfontengine_ft.cpp')
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 242c1d8d32..c13f60ff69 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1617,7 +1617,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag
face = lockFace();
g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyphs->glyphs[i], 0, Format_None, true);
glyphs->advances[i] = design ? QFixed::fromFixed(face->glyph->linearHoriAdvance >> 10)
- : QFixed::fromFixed(face->glyph->metrics.horiAdvance);
+ : QFixed::fromFixed(face->glyph->metrics.horiAdvance).round();
if (!cacheEnabled)
delete g;