Windows: Fix stored family name of fallback fonts

When we create fallback fonts, we copy the fontdef of the main font, but
we need to update the family name to match reality, otherwise a QRawFont
created with the font engine will have the wrong family name. This is
already done in the default implementation of loadEngine(), but was missing
from the Windows implementation.

One large consequence of this was that when the distance field renderer
cloned the font engine (to change its size), it would clone it with the
wrong family name. When it later painted its glyph indexes, they would
of course refer to the wrong font (the fallback) so random characters
would appear.

[ChangeLog][Windows] Fixed using QRawFont with fallback fonts, e.g.
in the case of text rendering in Qt Quick.

Task-number: QTBUG-39172
Change-Id: Ic8fcd9dfc20ec7aadf0b47d4a80417f401f355fd
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2014-08-06 13:40:46 +02:00 committed by Konstantin Ritt
parent 1671dacb52
commit 8306dee38f

View File

@ -1350,6 +1350,7 @@ void QWindowsMultiFontEngine::loadEngine(int at)
fontEngine->fontDef.pixelSize, fontEngine->fontDef.pixelSize,
data); data);
fedw->fontDef = fontDef; fedw->fontDef = fontDef;
fedw->fontDef.family = fam;
fedw->ref.ref(); fedw->ref.ref();
engines[at] = fedw; engines[at] = fedw;
@ -1375,6 +1376,7 @@ void QWindowsMultiFontEngine::loadEngine(int at)
engines[at] = new QWindowsFontEngine(fam, hfont, stockFont, lf, data); engines[at] = new QWindowsFontEngine(fam, hfont, stockFont, lf, data);
engines[at]->ref.ref(); engines[at]->ref.ref();
engines[at]->fontDef = fontDef; engines[at]->fontDef = fontDef;
engines[at]->fontDef.family = fam;
qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam; qCDebug(lcQpaFonts) << __FUNCTION__ << at << fam;
// TODO: increase cost in QFontCache for the font engine loaded here // TODO: increase cost in QFontCache for the font engine loaded here