Fix CJK languages support with HarfBuzz-NG

By some reason, mapping to Han script doesn't work for some (most?)
fonts. Until the issue is really fixed, pretend the HB-old behavior
and simply map to Common script.

Change-Id: I4c146f5ff2a42f64b971b2f5ebd7f65e2513fdf0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Konstantin Ritt 2014-03-10 17:25:10 +02:00 committed by The Qt Project
parent 4c9885a0f5
commit b7f013bf19

View File

@ -1506,18 +1506,8 @@ void QTextEngine::itemize() const
{ {
QVarLengthArray<uchar> scripts(length); QVarLengthArray<uchar> scripts(length);
QUnicodeTools::initScripts(string, length, scripts.data()); QUnicodeTools::initScripts(string, length, scripts.data());
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i)
ushort script = scripts.at(i); analysis[i].script = scripts.at(i);
switch (script) {
case QChar::Script_Hiragana:
case QChar::Script_Katakana:
script = QChar::Script_Han;
break;
default:
break;
}
analysis[i].script = script;
}
} }
const ushort *uc = string; const ushort *uc = string;
@ -1564,8 +1554,21 @@ void QTextEngine::itemize() const
(analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator; // to exclude it from width (analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator; // to exclude it from width
} }
#ifdef QT_ENABLE_HARFBUZZ_NG #ifdef QT_ENABLE_HARFBUZZ_NG
if (!useHarfbuzzNG) { analysis = scriptAnalysis.data();
analysis = scriptAnalysis.data(); if (useHarfbuzzNG) {
for (int i = 0; i < length; ++i) {
switch (analysis[i].script) {
case QChar::Script_Han:
case QChar::Script_Hiragana:
case QChar::Script_Katakana:
case QChar::Script_Bopomofo:
analysis[i].script = QChar::Script_Common;
break;
default:
break;
}
}
} else {
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
analysis[i].script = hbscript_to_script(script_to_hbscript(analysis[i].script)); analysis[i].script = hbscript_to_script(script_to_hbscript(analysis[i].script));
} }