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>
This commit is contained in:
Allan Sandfeld Jensen 2013-06-05 11:20:07 +02:00 committed by The Qt Project
parent 1828ab8557
commit 21356b3ec3
2 changed files with 16 additions and 3 deletions

View File

@ -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

View File

@ -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;