summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-06-05 11:20:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-07 18:07:21 +0200
commit21356b3ec34f4e83719389775b83825fbd8b02e6 (patch)
tree5aaf70fc5e28d37032110a7181543be4120cb064 /src/gui
parent1828ab8557e824ec22b0c425dd417df3a0794a8c (diff)
RecalcAdvances and DoKerning should agree on when to use design metrics
QFontEngineFT::recalcAdvances uses design metrics if hinting is disabled or slight. QFontEngine::doKerning only follows the QFontEngine::DesignMetrics flag. This means in some instances the advances will be calculated in subpixels but kerned in full pixels. This patch makes QFontEngineFT decide if it should request design metrics from QFontEngine::doKerning or not. Change-Id: Ia0236efde2d7269623f690a6074afbe26e07c458 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfontengine_ft.cpp18
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
2 files changed, 16 insertions, 3 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 10225febcb..4545645dc6 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1316,6 +1316,12 @@ void QFontEngineFT::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags) c
unlockFace();
}
}
+
+ if (shouldUseDesignMetrics(flags) && !(fontDef.styleStrategy & QFont::ForceIntegerMetrics))
+ flags |= DesignMetrics;
+ else
+ flags &= ~DesignMetrics;
+
QFontEngine::doKerning(g, flags);
}
@@ -1571,12 +1577,18 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
return true;
}
+bool QFontEngineFT::shouldUseDesignMetrics(QFontEngine::ShaperFlags flags) const
+{
+ if (!FT_IS_SCALABLE(freetype->face))
+ return false;
+
+ return default_hint_style == HintNone || default_hint_style == HintLight || (flags & DesignMetrics);
+}
+
void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
{
FT_Face face = 0;
- bool design = (default_hint_style == HintNone ||
- default_hint_style == HintLight ||
- (flags & DesignMetrics)) && FT_IS_SCALABLE(freetype->face);
+ bool design = shouldUseDesignMetrics(flags);
for (int i = 0; i < glyphs->numGlyphs; i++) {
Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : 0;
// Since we are passing Format_None to loadGlyph, use same default format logic as loadGlyph
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 434eb76c33..e09fa6f94f 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -325,6 +325,7 @@ private:
friend class QFontEngineMultiFontConfig;
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
+ bool shouldUseDesignMetrics(ShaperFlags flags) const;
GlyphFormat defaultFormat;
FT_Matrix matrix;