Fix font fallback for an overridden Common script cases
Always prefer the requested font, even if it doesn't support the script of interest, and fallback to a font that *does* support that script, so that the best-matching font always takes a precedence. The result looks much closer to what CT and GDI/DW does. Task-number: QTBUG-35836 Task-number: QTBUG-39377 Task-number: QTBUG-43408 Change-Id: I6a89593565683f318f7292ec5ecf271dadc4142a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
6e306e8d94
commit
c003a18ee3
@ -2669,7 +2669,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
|
|||||||
|
|
||||||
QtFontDesc desc;
|
QtFontDesc desc;
|
||||||
QList<int> blackListed;
|
QList<int> blackListed;
|
||||||
int index = match(script, request, family_name, foundry_name, &desc, blackListed);
|
int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
|
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
|
||||||
if (engine)
|
if (engine)
|
||||||
@ -2702,7 +2702,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
|
|||||||
if (!engine) {
|
if (!engine) {
|
||||||
QtFontDesc desc;
|
QtFontDesc desc;
|
||||||
do {
|
do {
|
||||||
index = match(script, def, def.family, QLatin1String(""), &desc, blackListed);
|
index = match(multi ? QChar::Script_Common : script, def, def.family, QLatin1String(""), &desc, blackListed);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
QFontDef loadDef = def;
|
QFontDef loadDef = def;
|
||||||
if (loadDef.family.isEmpty())
|
if (loadDef.family.isEmpty())
|
||||||
|
@ -167,6 +167,7 @@ private:
|
|||||||
friend class QFontDialog;
|
friend class QFontDialog;
|
||||||
friend class QFontDialogPrivate;
|
friend class QFontDialogPrivate;
|
||||||
friend class QFontEngineMulti;
|
friend class QFontEngineMulti;
|
||||||
|
friend class QRawFont;
|
||||||
|
|
||||||
QFontDatabasePrivate *d;
|
QFontDatabasePrivate *d;
|
||||||
};
|
};
|
||||||
|
@ -700,6 +700,20 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
|
|||||||
if (fe != 0 && fe->type() == QFontEngine::Multi) {
|
if (fe != 0 && fe->type() == QFontEngine::Multi) {
|
||||||
QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(fe);
|
QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(fe);
|
||||||
fe = multiEngine->engine(0);
|
fe = multiEngine->engine(0);
|
||||||
|
|
||||||
|
if (script > QChar::Script_Latin) {
|
||||||
|
// keep in sync with QFontEngineMulti::loadEngine()
|
||||||
|
QFontDef request(multiEngine->fontDef);
|
||||||
|
request.styleStrategy |= QFont::NoFontMerging;
|
||||||
|
|
||||||
|
if (QFontEngine *engine = QFontDatabase::findFont(request, script)) {
|
||||||
|
if (request.weight > QFont::Normal)
|
||||||
|
engine->fontDef.weight = request.weight;
|
||||||
|
if (request.style > QFont::StyleNormal)
|
||||||
|
engine->fontDef.style = request.style;
|
||||||
|
fe = engine;
|
||||||
|
}
|
||||||
|
}
|
||||||
Q_ASSERT(fe);
|
Q_ASSERT(fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user