Update Qt internals to use QChar::Script

...and remove the outdated QUnicodeTables::Script enum.
QFontEngineData now has one extra slot that never used
(engines[QChar::Script_Inherited]). engines[QChar::Script_Unknown],
if accessed, would be set with a Box engine instance, and could be used
as a minor optimization some time later.

In order to preserve the existing behavior, we map all scripts up to Latin to Common.

Change-Id: Ide4182a0f8447b4bf25713ecc3fe8097b8fed040
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Konstantin Ritt 2012-12-21 18:35:58 +02:00 committed by The Qt Project
parent dde09c429a
commit 9b0fab6b62
31 changed files with 349 additions and 555 deletions

View File

@ -53,11 +53,86 @@
#ifndef QHARFBUZZ_P_H
#define QHARFBUZZ_P_H
#include <QtCore/qglobal.h>
#include <QtCore/qchar.h>
#include <harfbuzz-shaper.h>
QT_BEGIN_NAMESPACE
static inline HB_Script script_to_hbscript(uchar script)
{
switch (script) {
case QChar::Script_Inherited: return HB_Script_Inherited;
case QChar::Script_Common: return HB_Script_Common;
case QChar::Script_Arabic: return HB_Script_Arabic;
case QChar::Script_Armenian: return HB_Script_Armenian;
case QChar::Script_Bengali: return HB_Script_Bengali;
case QChar::Script_Cyrillic: return HB_Script_Cyrillic;
case QChar::Script_Devanagari: return HB_Script_Devanagari;
case QChar::Script_Georgian: return HB_Script_Georgian;
case QChar::Script_Greek: return HB_Script_Greek;
case QChar::Script_Gujarati: return HB_Script_Gujarati;
case QChar::Script_Gurmukhi: return HB_Script_Gurmukhi;
case QChar::Script_Hangul: return HB_Script_Hangul;
case QChar::Script_Hebrew: return HB_Script_Hebrew;
case QChar::Script_Kannada: return HB_Script_Kannada;
case QChar::Script_Khmer: return HB_Script_Khmer;
case QChar::Script_Lao: return HB_Script_Lao;
case QChar::Script_Malayalam: return HB_Script_Malayalam;
case QChar::Script_Myanmar: return HB_Script_Myanmar;
case QChar::Script_Ogham: return HB_Script_Ogham;
case QChar::Script_Oriya: return HB_Script_Oriya;
case QChar::Script_Runic: return HB_Script_Runic;
case QChar::Script_Sinhala: return HB_Script_Sinhala;
case QChar::Script_Syriac: return HB_Script_Syriac;
case QChar::Script_Tamil: return HB_Script_Tamil;
case QChar::Script_Telugu: return HB_Script_Telugu;
case QChar::Script_Thaana: return HB_Script_Thaana;
case QChar::Script_Thai: return HB_Script_Thai;
case QChar::Script_Tibetan: return HB_Script_Tibetan;
case QChar::Script_Nko: return HB_Script_Nko;
default: break;
};
return HB_Script_Common;
}
static inline uchar hbscript_to_script(uchar script)
{
switch (script) {
case HB_Script_Inherited: return QChar::Script_Inherited;
case HB_Script_Common: return QChar::Script_Common;
case HB_Script_Arabic: return QChar::Script_Arabic;
case HB_Script_Armenian: return QChar::Script_Armenian;
case HB_Script_Bengali: return QChar::Script_Bengali;
case HB_Script_Cyrillic: return QChar::Script_Cyrillic;
case HB_Script_Devanagari: return QChar::Script_Devanagari;
case HB_Script_Georgian: return QChar::Script_Georgian;
case HB_Script_Greek: return QChar::Script_Greek;
case HB_Script_Gujarati: return QChar::Script_Gujarati;
case HB_Script_Gurmukhi: return QChar::Script_Gurmukhi;
case HB_Script_Hangul: return QChar::Script_Hangul;
case HB_Script_Hebrew: return QChar::Script_Hebrew;
case HB_Script_Kannada: return QChar::Script_Kannada;
case HB_Script_Khmer: return QChar::Script_Khmer;
case HB_Script_Lao: return QChar::Script_Lao;
case HB_Script_Malayalam: return QChar::Script_Malayalam;
case HB_Script_Myanmar: return QChar::Script_Myanmar;
case HB_Script_Ogham: return QChar::Script_Ogham;
case HB_Script_Oriya: return QChar::Script_Oriya;
case HB_Script_Runic: return QChar::Script_Runic;
case HB_Script_Sinhala: return QChar::Script_Sinhala;
case HB_Script_Syriac: return QChar::Script_Syriac;
case HB_Script_Tamil: return QChar::Script_Tamil;
case HB_Script_Telugu: return QChar::Script_Telugu;
case HB_Script_Thaana: return QChar::Script_Thaana;
case HB_Script_Thai: return QChar::Script_Thai;
case HB_Script_Tibetan: return QChar::Script_Tibetan;
case HB_Script_Nko: return QChar::Script_Nko;
default: break;
};
return QChar::Script_Common;
}
Q_CORE_EXPORT HB_Bool qShapeItem(HB_ShaperItem *item);
// ### temporary

View File

@ -41,7 +41,6 @@
#include <QtCore/qtextboundaryfinder.h>
#include <QtCore/qvarlengtharray.h>
#include <private/qunicodetables_p.h>
#include <private/qunicodetools_p.h>
QT_BEGIN_NAMESPACE
@ -61,15 +60,15 @@ static void init(QTextBoundaryFinder::BoundaryType type, const QChar *chars, int
// correctly assign script, isTab and isObject to the script analysis
const ushort *uc = unicode;
const ushort *e = uc + length;
int script = QUnicodeTables::Common;
int lastScript = QUnicodeTables::Common;
uchar script = QChar::Script_Common;
uchar lastScript = QChar::Script_Common;
const ushort *start = uc;
while (uc < e) {
int s = QUnicodeTables::script(*uc);
if (s != QUnicodeTables::Inherited)
int s = QChar::script(*uc);
if (s != QChar::Script_Inherited)
script = s;
if (*uc == QChar::ObjectReplacementCharacter || *uc == QChar::LineSeparator || *uc == 9)
script = QUnicodeTables::Common;
script = QChar::Script_Common;
if (script != lastScript) {
if (uc != start) {
QUnicodeTools::ScriptItem item;

View File

@ -6724,43 +6724,6 @@ Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4)
return (LineBreakClass)qGetProp(ucs4)->lineBreakClass;
}
Q_CORE_EXPORT Script QT_FASTCALL script(uint ucs4)
{
switch (qGetProp(ucs4)->script) {
case QChar::Script_Inherited: return Inherited;
case QChar::Script_Common: return Common;
case QChar::Script_Arabic: return Arabic;
case QChar::Script_Armenian: return Armenian;
case QChar::Script_Bengali: return Bengali;
case QChar::Script_Cyrillic: return Cyrillic;
case QChar::Script_Devanagari: return Devanagari;
case QChar::Script_Georgian: return Georgian;
case QChar::Script_Greek: return Greek;
case QChar::Script_Gujarati: return Gujarati;
case QChar::Script_Gurmukhi: return Gurmukhi;
case QChar::Script_Hangul: return Hangul;
case QChar::Script_Hebrew: return Hebrew;
case QChar::Script_Kannada: return Kannada;
case QChar::Script_Khmer: return Khmer;
case QChar::Script_Lao: return Lao;
case QChar::Script_Malayalam: return Malayalam;
case QChar::Script_Myanmar: return Myanmar;
case QChar::Script_Ogham: return Ogham;
case QChar::Script_Oriya: return Oriya;
case QChar::Script_Runic: return Runic;
case QChar::Script_Sinhala: return Sinhala;
case QChar::Script_Syriac: return Syriac;
case QChar::Script_Tamil: return Tamil;
case QChar::Script_Telugu: return Telugu;
case QChar::Script_Thaana: return Thaana;
case QChar::Script_Thai: return Thai;
case QChar::Script_Tibetan: return Tibetan;
case QChar::Script_Nko: return Nko;
default: break;
};
return Common;
}
static const ushort specialCaseMap[] = {
0x0, // placeholder

View File

@ -89,113 +89,6 @@ struct Properties {
Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4);
Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2);
// See http://www.unicode.org/reports/tr24/tr24-5.html
enum Script {
Common,
Greek,
Cyrillic,
Armenian,
Hebrew,
Arabic,
Syriac,
Thaana,
Devanagari,
Bengali,
Gurmukhi,
Gujarati,
Oriya,
Tamil,
Telugu,
Kannada,
Malayalam,
Sinhala,
Thai,
Lao,
Tibetan,
Myanmar,
Georgian,
Hangul,
Ogham,
Runic,
Khmer,
Nko,
Inherited,
ScriptCount = Inherited,
Latin = Common,
Ethiopic = Common,
Cherokee = Common,
CanadianAboriginal = Common,
Mongolian = Common,
Hiragana = Common,
Katakana = Common,
Bopomofo = Common,
Han = Common,
Yi = Common,
OldItalic = Common,
Gothic = Common,
Deseret = Common,
Tagalog = Common,
Hanunoo = Common,
Buhid = Common,
Tagbanwa = Common,
Limbu = Common,
TaiLe = Common,
LinearB = Common,
Ugaritic = Common,
Shavian = Common,
Osmanya = Common,
Cypriot = Common,
Braille = Common,
Buginese = Common,
Coptic = Common,
NewTaiLue = Common,
Glagolitic = Common,
Tifinagh = Common,
SylotiNagri = Common,
OldPersian = Common,
Kharoshthi = Common,
Balinese = Common,
Cuneiform = Common,
Phoenician = Common,
PhagsPa = Common,
Sundanese = Common,
Lepcha = Common,
OlChiki = Common,
Vai = Common,
Saurashtra = Common,
KayahLi = Common,
Rejang = Common,
Lycian = Common,
Carian = Common,
Lydian = Common,
Cham = Common,
TaiTham = Common,
TaiViet = Common,
Avestan = Common,
EgyptianHieroglyphs = Common,
Samaritan = Common,
Lisu = Common,
Bamum = Common,
Javanese = Common,
MeeteiMayek = Common,
ImperialAramaic = Common,
OldSouthArabian = Common,
InscriptionalParthian = Common,
InscriptionalPahlavi = Common,
OldTurkic = Common,
Kaithi = Common,
Batak = Common,
Brahmi = Common,
Mandaic = Common,
Chakma = Common,
MeroiticCursive = Common,
MeroiticHieroglyphs = Common,
Miao = Common,
Sharada = Common,
SoraSompeng = Common,
Takri = Common
};
enum GraphemeBreakClass {
GraphemeBreak_Other,
GraphemeBreak_CR,
@ -274,10 +167,6 @@ Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4);
inline LineBreakClass lineBreakClass(QChar ch)
{ return lineBreakClass(ch.unicode()); }
Q_CORE_EXPORT Script QT_FASTCALL script(uint ucs4);
inline Script script(QChar ch)
{ return script(ch.unicode()); }
} // namespace QUnicodeTables
QT_END_NAMESPACE

View File

@ -44,7 +44,7 @@
#include "qunicodetables_p.h"
#include "qvarlengtharray.h"
#include <harfbuzz-shaper.h>
#include "qharfbuzz_p.h"
#define FLAG(x) (1 << (x))
@ -615,7 +615,7 @@ Q_CORE_EXPORT void initCharAttributes(const ushort *string, int length,
HB_ScriptItem item;
item.pos = items[start].position;
item.length = items[i].position - items[start].position;
item.script = (HB_Script)items[start].script;
item.script = script_to_hbscript(items[start].script);
item.bidiLevel = 0; // unused
scriptItems.append(item);
start = i;
@ -624,7 +624,7 @@ Q_CORE_EXPORT void initCharAttributes(const ushort *string, int length,
HB_ScriptItem item;
item.pos = items[start].position;
item.length = length - items[start].position;
item.script = (HB_Script)items[start].script;
item.script = script_to_hbscript(items[start].script);
item.bidiLevel = 0; // unused
scriptItems.append(item);
}

View File

@ -1752,7 +1752,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
QRawFont rawFont;
QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont);
QFontPrivate *fontD = QFontPrivate::get(font);
rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common);
rawFontD->fontEngine = fontD->engineForScript(QChar::Script_Common);
rawFontD->fontEngine->ref.ref();
QGlyphRun glyphs;

View File

@ -5738,7 +5738,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText
return;
}
QFontEngine *fe = staticText_d->font.d->engineForScript(QUnicodeTables::Common);
QFontEngine *fe = staticText_d->font.d->engineForScript(QChar::Script_Common);
if (fe->type() == QFontEngine::Multi)
fe = static_cast<QFontEngineMulti *>(fe)->engine(0);
bool supportsTransformations = d->extended->supportsTransformations(fe,
@ -5845,7 +5845,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif
int len = str.length();
int numGlyphs = len;
QVarLengthGlyphLayoutArray glyphs(len);
QFontEngine *fontEngine = d->state->font.d->engineForScript(QUnicodeTables::Common);
QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common);
if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) {
glyphs.resize(numGlyphs);
if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0))

View File

@ -55,7 +55,6 @@
#include "qthread.h"
#include "qthreadstorage.h"
#include <private/qunicodetables_p.h>
#include "qfont_p.h"
#include <private/qfontengine_p.h>
#include <private/qpainter_p.h>
@ -207,8 +206,8 @@ extern QMutex *qt_fontdatabase_mutex();
QFontEngine *QFontPrivate::engineForScript(int script) const
{
QMutexLocker locker(qt_fontdatabase_mutex());
if (script >= QUnicodeTables::Inherited)
script = QUnicodeTables::Common;
if (script <= QChar::Script_Latin)
script = QChar::Script_Common;
if (engineData && engineData->fontCache != QFontCache::instance()) {
// throw out engineData that came from a different thread
engineData->ref.deref();
@ -319,12 +318,12 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other)
QFontEngineData::QFontEngineData()
: ref(1), fontCache(QFontCache::instance())
{
memset(engines, 0, QUnicodeTables::ScriptCount * sizeof(QFontEngine *));
memset(engines, 0, QChar::ScriptCount * sizeof(QFontEngine *));
}
QFontEngineData::~QFontEngineData()
{
for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
for (int i = 0; i < QChar::ScriptCount; ++i) {
if (engines[i])
engines[i]->ref.deref();
engines[i] = 0;
@ -1667,7 +1666,7 @@ void QFont::setRawMode(bool enable)
*/
bool QFont::exactMatch() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (d->rawMode
? engine->type() != QFontEngine::Box
@ -2363,7 +2362,7 @@ QFontInfo &QFontInfo::operator=(const QFontInfo &fi)
*/
QString QFontInfo::family() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.family;
}
@ -2378,7 +2377,7 @@ QString QFontInfo::family() const
*/
QString QFontInfo::styleName() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.styleName;
}
@ -2390,7 +2389,7 @@ QString QFontInfo::styleName() const
*/
int QFontInfo::pointSize() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->fontDef.pointSize);
}
@ -2402,7 +2401,7 @@ int QFontInfo::pointSize() const
*/
qreal QFontInfo::pointSizeF() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.pointSize;
}
@ -2414,7 +2413,7 @@ qreal QFontInfo::pointSizeF() const
*/
int QFontInfo::pixelSize() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.pixelSize;
}
@ -2426,7 +2425,7 @@ int QFontInfo::pixelSize() const
*/
bool QFontInfo::italic() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.style != QFont::StyleNormal;
}
@ -2438,7 +2437,7 @@ bool QFontInfo::italic() const
*/
QFont::Style QFontInfo::style() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (QFont::Style)engine->fontDef.style;
}
@ -2450,7 +2449,7 @@ QFont::Style QFontInfo::style() const
*/
int QFontInfo::weight() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->fontDef.weight;
@ -2515,7 +2514,7 @@ bool QFontInfo::strikeOut() const
*/
bool QFontInfo::fixedPitch() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
#ifdef Q_OS_MAC
if (!engine->fontDef.fixedPitchComputed) {
@ -2539,7 +2538,7 @@ bool QFontInfo::fixedPitch() const
*/
QFont::StyleHint QFontInfo::styleHint() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (QFont::StyleHint) engine->fontDef.styleHint;
}
@ -2567,7 +2566,7 @@ bool QFontInfo::rawMode() const
*/
bool QFontInfo::exactMatch() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (d->rawMode
? engine->type() != QFontEngine::Box
@ -2675,7 +2674,7 @@ void QFontCache::clear()
end = engineDataCache.end();
while (it != end) {
QFontEngineData *data = it.value();
for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
for (int i = 0; i < QChar::ScriptCount; ++i) {
if (data->engines[i]) {
data->engines[i]->ref.deref();
data->engines[i] = 0;

View File

@ -57,7 +57,6 @@
#include "QtCore/qmap.h"
#include "QtCore/qobject.h"
#include "QtCore/qstringlist.h"
#include <private/qunicodetables_p.h>
#include <QtGui/qfontdatabase.h>
#include "private/qfixed_p.h"
@ -143,7 +142,7 @@ public:
QAtomicInt ref;
QFontCache *fontCache;
QFontEngine *engines[QUnicodeTables::ScriptCount];
QFontEngine *engines[QChar::ScriptCount];
};

View File

@ -72,7 +72,7 @@ QString QFont::defaultFamily() const
{
QPlatformFontDatabase *fontDB = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
const QStringList fallbacks = fontDB->fallbacksForFamily(QString(), QFont::StyleNormal
, QFont::StyleHint(d->request.styleHint), QUnicodeTables::Common);
, QFont::StyleHint(d->request.styleHint), QChar::Script_Common);
if (!fallbacks.isEmpty())
return fallbacks.first();
return QString();

View File

@ -48,7 +48,6 @@
#include "qmutex.h"
#include "qfile.h"
#include "qfileinfo.h"
#include "private/qunicodetables_p.h"
#include "qfontengine_p.h"
#include <qpa/qplatformintegration.h>
@ -614,48 +613,48 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
static const int scriptForWritingSystem[] = {
QUnicodeTables::Common, // Any
QUnicodeTables::Latin, // Latin
QUnicodeTables::Greek, // Greek
QUnicodeTables::Cyrillic, // Cyrillic
QUnicodeTables::Armenian, // Armenian
QUnicodeTables::Hebrew, // Hebrew
QUnicodeTables::Arabic, // Arabic
QUnicodeTables::Syriac, // Syriac
QUnicodeTables::Thaana, // Thaana
QUnicodeTables::Devanagari, // Devanagari
QUnicodeTables::Bengali, // Bengali
QUnicodeTables::Gurmukhi, // Gurmukhi
QUnicodeTables::Gujarati, // Gujarati
QUnicodeTables::Oriya, // Oriya
QUnicodeTables::Tamil, // Tamil
QUnicodeTables::Telugu, // Telugu
QUnicodeTables::Kannada, // Kannada
QUnicodeTables::Malayalam, // Malayalam
QUnicodeTables::Sinhala, // Sinhala
QUnicodeTables::Thai, // Thai
QUnicodeTables::Lao, // Lao
QUnicodeTables::Tibetan, // Tibetan
QUnicodeTables::Myanmar, // Myanmar
QUnicodeTables::Georgian, // Georgian
QUnicodeTables::Khmer, // Khmer
QUnicodeTables::Common, // SimplifiedChinese
QUnicodeTables::Common, // TraditionalChinese
QUnicodeTables::Common, // Japanese
QUnicodeTables::Hangul, // Korean
QUnicodeTables::Common, // Vietnamese
QUnicodeTables::Common, // Yi
QUnicodeTables::Common, // Tagalog
QUnicodeTables::Common, // Hanunoo
QUnicodeTables::Common, // Buhid
QUnicodeTables::Common, // Tagbanwa
QUnicodeTables::Common, // Limbu
QUnicodeTables::Common, // TaiLe
QUnicodeTables::Common, // Braille
QUnicodeTables::Common, // Symbol
QUnicodeTables::Ogham, // Ogham
QUnicodeTables::Runic, // Runic
QUnicodeTables::Nko // Nko
QChar::Script_Common, // Any
QChar::Script_Latin, // Latin
QChar::Script_Greek, // Greek
QChar::Script_Cyrillic, // Cyrillic
QChar::Script_Armenian, // Armenian
QChar::Script_Hebrew, // Hebrew
QChar::Script_Arabic, // Arabic
QChar::Script_Syriac, // Syriac
QChar::Script_Thaana, // Thaana
QChar::Script_Devanagari, // Devanagari
QChar::Script_Bengali, // Bengali
QChar::Script_Gurmukhi, // Gurmukhi
QChar::Script_Gujarati, // Gujarati
QChar::Script_Oriya, // Oriya
QChar::Script_Tamil, // Tamil
QChar::Script_Telugu, // Telugu
QChar::Script_Kannada, // Kannada
QChar::Script_Malayalam, // Malayalam
QChar::Script_Sinhala, // Sinhala
QChar::Script_Thai, // Thai
QChar::Script_Lao, // Lao
QChar::Script_Tibetan, // Tibetan
QChar::Script_Myanmar, // Myanmar
QChar::Script_Georgian, // Georgian
QChar::Script_Khmer, // Khmer
QChar::Script_Han, // SimplifiedChinese
QChar::Script_Han, // TraditionalChinese
QChar::Script_Han, // Japanese
QChar::Script_Hangul, // Korean
QChar::Script_Latin, // Vietnamese
QChar::Script_Yi, // Yi
QChar::Script_Tagalog, // Tagalog
QChar::Script_Hanunoo, // Hanunoo
QChar::Script_Buhid, // Buhid
QChar::Script_Tagbanwa, // Tagbanwa
QChar::Script_Limbu, // Limbu
QChar::Script_TaiLe, // TaiLe
QChar::Script_Braille, // Braille
QChar::Script_Common, // Symbol
QChar::Script_Ogham, // Ogham
QChar::Script_Runic, // Runic
QChar::Script_Nko // Nko
};
int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
@ -1072,7 +1071,7 @@ static void match(int script, const QFontDef &request,
uint score_adjust = 0;
bool supported = (script == QUnicodeTables::Common);
bool supported = (script == QChar::Script_Common);
for (int ws = 1; !supported && ws < QFontDatabase::WritingSystemsCount; ++ws) {
if (scriptForWritingSystem[ws] != script)
continue;

View File

@ -103,7 +103,7 @@ Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const
f->aliases.push_back(alias);
}
static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script)
static QStringList fallbackFamilies(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
{
QStringList retList = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
QFontDatabasePrivate *db = privateDb();
@ -174,7 +174,7 @@ QFontEngine *loadSingleEngine(int script,
QFontCache::Key key(def,script);
QFontEngine *engine = QFontCache::instance()->findEngine(key);
if (!engine) {
engine = pfdb->fontEngine(def,QUnicodeTables::Script(script),size->handle);
engine = pfdb->fontEngine(def, QChar::Script(script), size->handle);
if (engine) {
QFontCache::Key key(def,script);
QFontCache::instance()->instance()->insertEngine(key,engine);
@ -199,7 +199,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
if (styleHint == QFont::AnyStyle && request.fixedPitch)
styleHint = QFont::TypeWriter;
family->fallbackFamilies = fallbackFamilies(family->name,fontStyle,styleHint,QUnicodeTables::Script(script));
family->fallbackFamilies = fallbackFamilies(family->name, fontStyle, styleHint, QChar::Script(script));
family->askedForFallback = true;
}
@ -209,7 +209,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
fallbacks = family->fallbackFamilies;
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QUnicodeTables::Script(script));
QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));
pfMultiEngine->setFallbackFamiliesList(fallbacks);
engine = pfMultiEngine;
@ -321,7 +321,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
+ fallbackFamilies(request.family,
QFont::Style(request.style),
QFont::StyleHint(request.styleHint),
QUnicodeTables::Script(script));
QChar::Script(script));
for (int i = 0; !engine && i < fallbacks.size(); i++) {
QFontDef def = request;
@ -426,7 +426,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
}
if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) {
for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
for (int i = 0; i < QChar::ScriptCount; ++i) {
if (!d->engineData->engines[i]) {
d->engineData->engines[i] = fe;
fe->ref.ref();

View File

@ -710,7 +710,7 @@ void QFontEngineMultiQPA::ensureFallbackFamiliesQueried()
if (fallbacksQueried)
return;
QStringList fallbacks = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fallbacksForFamily(engine(0)->fontDef.family, QFont::Style(engine(0)->fontDef.style)
, QFont::AnyStyle, QUnicodeTables::Script(script));
, QFont::AnyStyle, QChar::Script(script));
setFallbackFamiliesList(fallbacks);
}
@ -762,7 +762,7 @@ QFontEngine* QFontEngineMultiQPA::createMultiFontEngine(QFontEngine *fe, int scr
it++;
}
if (!engine) {
engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QUnicodeTables::Script(script));
engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QChar::Script(script));
QFontCache::instance()->insertEngine(key, engine, /* insertMulti */ !faceIsLocal);
}
Q_ASSERT(engine);

View File

@ -45,7 +45,6 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include <private/qunicodetables_p.h>
#include <math.h>
@ -262,7 +261,7 @@ bool QFontMetrics::operator ==(const QFontMetrics &other) const
*/
int QFontMetrics::ascent() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->ascent());
}
@ -280,7 +279,7 @@ int QFontMetrics::ascent() const
*/
int QFontMetrics::descent() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->descent());
}
@ -295,7 +294,7 @@ int QFontMetrics::descent() const
*/
int QFontMetrics::height() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->ascent()) + qRound(engine->descent());
}
@ -309,7 +308,7 @@ int QFontMetrics::height() const
*/
int QFontMetrics::leading() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->leading());
}
@ -323,7 +322,7 @@ int QFontMetrics::leading() const
*/
int QFontMetrics::lineSpacing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent());
}
@ -340,7 +339,7 @@ int QFontMetrics::lineSpacing() const
*/
int QFontMetrics::minLeftBearing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->minLeftBearing());
}
@ -357,7 +356,7 @@ int QFontMetrics::minLeftBearing() const
*/
int QFontMetrics::minRightBearing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->minRightBearing());
}
@ -367,7 +366,7 @@ int QFontMetrics::minRightBearing() const
*/
int QFontMetrics::maxWidth() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->maxCharWidth());
}
@ -378,10 +377,10 @@ int QFontMetrics::maxWidth() const
*/
int QFontMetrics::xHeight() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
if (d->capital == QFont::SmallCaps)
return qRound(d->smallCapsFontPrivate()->engineForScript(QUnicodeTables::Common)->ascent());
return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent());
return qRound(engine->xHeight());
}
@ -392,7 +391,7 @@ int QFontMetrics::xHeight() const
*/
int QFontMetrics::averageCharWidth() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->averageCharWidth());
}
@ -403,7 +402,7 @@ int QFontMetrics::averageCharWidth() const
*/
bool QFontMetrics::inFont(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@ -417,7 +416,7 @@ bool QFontMetrics::inFont(QChar ch) const
*/
bool QFontMetrics::inFontUcs4(uint ucs4) const
{
const int script = QUnicodeTables::script(ucs4);
const int script = QChar::script(ucs4);
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@ -439,7 +438,7 @@ bool QFontMetrics::inFontUcs4(uint ucs4) const
*/
int QFontMetrics::leftBearing(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -474,7 +473,7 @@ int QFontMetrics::leftBearing(QChar ch) const
*/
int QFontMetrics::rightBearing(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -530,7 +529,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const
// Skip harfbuzz complex shaping, only use advances
int numGlyphs = len;
QVarLengthGlyphLayoutArray glyphs(numGlyphs);
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0)) {
glyphs.resize(numGlyphs);
if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0))
@ -577,7 +576,7 @@ int QFontMetrics::width(QChar ch) const
if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing)
return 0;
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -607,14 +606,13 @@ int QFontMetrics::width(QChar ch) const
*/
int QFontMetrics::charWidth(const QString &text, int pos) const
{
int width = 0;
if (pos < 0 || pos > (int)text.length())
return 0;
return width;
QChar ch = text.unicode()[pos];
const int script = QUnicodeTables::script(ch);
int width;
if (script != QUnicodeTables::Common) {
QChar ch = text.at(pos);
const int script = ch.script();
if (script != QChar::Script_Common) {
// complex script shaping. Have to do some hard work
int from = qMax(0, pos - 8);
int to = qMin(text.length(), pos + 8);
@ -623,9 +621,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const
layout.ignoreBidi = true;
layout.itemize();
width = qRound(layout.width(pos-from, 1));
} else if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing) {
width = 0;
} else {
} else if (ch.category() != QChar::Mark_NonSpacing) {
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -694,7 +690,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const
*/
QRect QFontMetrics::boundingRect(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -895,7 +891,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in
*/
int QFontMetrics::underlinePos() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->underlinePosition());
}
@ -931,7 +927,7 @@ int QFontMetrics::strikeOutPos() const
*/
int QFontMetrics::lineWidth() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return qRound(engine->lineThickness());
}
@ -1129,7 +1125,7 @@ bool QFontMetricsF::operator ==(const QFontMetricsF &other) const
*/
qreal QFontMetricsF::ascent() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->ascent().toReal();
}
@ -1148,7 +1144,7 @@ qreal QFontMetricsF::ascent() const
*/
qreal QFontMetricsF::descent() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->descent().toReal();
}
@ -1163,7 +1159,7 @@ qreal QFontMetricsF::descent() const
*/
qreal QFontMetricsF::height() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (engine->ascent() + engine->descent()).toReal();
@ -1178,7 +1174,7 @@ qreal QFontMetricsF::height() const
*/
qreal QFontMetricsF::leading() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->leading().toReal();
}
@ -1192,7 +1188,7 @@ qreal QFontMetricsF::leading() const
*/
qreal QFontMetricsF::lineSpacing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return (engine->leading() + engine->ascent() + engine->descent()).toReal();
}
@ -1209,7 +1205,7 @@ qreal QFontMetricsF::lineSpacing() const
*/
qreal QFontMetricsF::minLeftBearing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->minLeftBearing();
}
@ -1226,7 +1222,7 @@ qreal QFontMetricsF::minLeftBearing() const
*/
qreal QFontMetricsF::minRightBearing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->minRightBearing();
}
@ -1236,7 +1232,7 @@ qreal QFontMetricsF::minRightBearing() const
*/
qreal QFontMetricsF::maxWidth() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->maxCharWidth();
}
@ -1247,10 +1243,10 @@ qreal QFontMetricsF::maxWidth() const
*/
qreal QFontMetricsF::xHeight() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
if (d->capital == QFont::SmallCaps)
return d->smallCapsFontPrivate()->engineForScript(QUnicodeTables::Common)->ascent().toReal();
return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal();
return engine->xHeight().toReal();
}
@ -1261,7 +1257,7 @@ qreal QFontMetricsF::xHeight() const
*/
qreal QFontMetricsF::averageCharWidth() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->averageCharWidth().toReal();
}
@ -1272,7 +1268,7 @@ qreal QFontMetricsF::averageCharWidth() const
*/
bool QFontMetricsF::inFont(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@ -1288,7 +1284,7 @@ bool QFontMetricsF::inFont(QChar ch) const
*/
bool QFontMetricsF::inFontUcs4(uint ucs4) const
{
const int script = QUnicodeTables::script(ucs4);
const int script = QChar::script(ucs4);
QFontEngine *engine = d->engineForScript(script);
Q_ASSERT(engine != 0);
if (engine->type() == QFontEngine::Box)
@ -1310,7 +1306,7 @@ bool QFontMetricsF::inFontUcs4(uint ucs4) const
*/
qreal QFontMetricsF::leftBearing(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -1345,7 +1341,7 @@ qreal QFontMetricsF::leftBearing(QChar ch) const
*/
qreal QFontMetricsF::rightBearing(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -1414,10 +1410,10 @@ qreal QFontMetricsF::width(const QString &text) const
*/
qreal QFontMetricsF::width(QChar ch) const
{
if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing)
if (ch.category() == QChar::Mark_NonSpacing)
return 0.;
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -1482,7 +1478,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const
*/
QRectF QFontMetricsF::boundingRect(QChar ch) const
{
const int script = QUnicodeTables::script(ch);
const int script = ch.script();
QFontEngine *engine;
if (d->capital == QFont::SmallCaps && ch.isLower())
engine = d->smallCapsFontPrivate()->engineForScript(script);
@ -1682,7 +1678,7 @@ QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, q
*/
qreal QFontMetricsF::underlinePos() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->underlinePosition().toReal();
}
@ -1717,7 +1713,7 @@ qreal QFontMetricsF::strikeOutPos() const
*/
qreal QFontMetricsF::lineWidth() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
return engine->lineThickness().toReal();
}

View File

@ -276,8 +276,7 @@ void QPlatformFontDatabase::populateFontDatabase()
option to fall back to the fonts given by \a fallbacks if \a fontEngine does not support
a certain character.
*/
QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine,
QUnicodeTables::Script script)
QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
{
return new QFontEngineMultiQPA(fontEngine, script);
}
@ -286,7 +285,7 @@ QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine
Returns the font engine that can be used to render the font described by
the font definition, \a fontDef, in the specified \a script.
*/
QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle)
QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle)
{
Q_UNUSED(script);
Q_UNUSED(handle);
@ -310,7 +309,7 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal
Returns a list of alternative fonts for the specified \a family and
\a style and \a script using the \a styleHint given.
*/
QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
Q_UNUSED(family);
Q_UNUSED(style);

View File

@ -98,9 +98,9 @@ class Q_GUI_EXPORT QPlatformFontDatabase
public:
virtual ~QPlatformFontDatabase();
virtual void populateFontDatabase();
virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script);
virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
virtual QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
virtual void releaseHandle(void *handle);

View File

@ -51,7 +51,6 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qstring.h"
#include <private/qunicodetables_p.h>
#include "qtextdocument_p.h"
#include "qrawfont.h"
#include "qrawfont_p.h"
@ -134,7 +133,7 @@ private:
// along, and nothing else.
if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
&& m_analysis[i].flags == m_analysis[start].flags
&& (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.'))
&& (script_to_hbscript(m_analysis[i].script) == script_to_hbscript(m_analysis[start].script) || m_string[i] == QLatin1Char('.'))
&& m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
&& i - start < MaxItemLength)
continue;
@ -1004,7 +1003,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
memset(&entire_shaper_item, 0, sizeof(entire_shaper_item));
entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(layoutData->string.constData());
entire_shaper_item.stringLength = layoutData->string.length();
entire_shaper_item.item.script = (HB_Script)si.analysis.script;
entire_shaper_item.item.script = script_to_hbscript(si.analysis.script);
entire_shaper_item.item.pos = si.position;
entire_shaper_item.item.length = length(item);
entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;
@ -1348,42 +1347,44 @@ void QTextEngine::itemize() const
const ushort *uc = reinterpret_cast<const ushort *>(layoutData->string.unicode());
const ushort *e = uc + length;
int lastScript = QUnicodeTables::Common;
uchar lastScript = QChar::Script_Common;
while (uc < e) {
switch (*uc) {
case QChar::ObjectReplacementCharacter:
analysis->script = QUnicodeTables::Common;
analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::Object;
break;
case QChar::LineSeparator:
if (analysis->bidiLevel % 2)
--analysis->bidiLevel;
analysis->script = QUnicodeTables::Common;
analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::LineOrParagraphSeparator;
if (option.flags() & QTextOption::ShowLineAndParagraphSeparators)
*const_cast<ushort*>(uc) = 0x21B5; // visual line separator
break;
case QChar::Tabulation:
analysis->script = QUnicodeTables::Common;
analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::Tab;
analysis->bidiLevel = control.baseLevel();
break;
case QChar::Space:
case QChar::Nbsp:
if (option.flags() & QTextOption::ShowTabsAndSpaces) {
analysis->script = QUnicodeTables::Common;
analysis->script = QChar::Script_Common;
analysis->flags = QScriptAnalysis::Space;
analysis->bidiLevel = control.baseLevel();
break;
}
// fall through
default:
int script = QUnicodeTables::script(*uc);
analysis->script = script == QUnicodeTables::Inherited ? lastScript : script;
analysis->script = QChar::script(*uc);
if (analysis->script == QChar::Script_Inherited)
analysis->script = lastScript;
analysis->flags = QScriptAnalysis::None;
break;
}
lastScript = analysis->script;
analysis->script = hbscript_to_script(script_to_hbscript(analysis->script)); // retain the old behavior
++uc;
++analysis;
}
@ -2033,9 +2034,9 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng)
QPaintDevice *pdev = eng->block.docHandle()->layout()->paintDevice();
if (pdev)
f = QFont(f, pdev);
e = f.d->engineForScript(QUnicodeTables::Common);
e = f.d->engineForScript(QChar::Script_Common);
} else {
e = eng->fnt.d->engineForScript(QUnicodeTables::Common);
e = eng->fnt.d->engineForScript(QChar::Script_Common);
}
QFixed other_ascent = e->ascent();
@ -2419,7 +2420,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
{
QChar ellipsisChar(0x2026);
QFontEngine *fe = fnt.d->engineForScript(QUnicodeTables::Common);
QFontEngine *fe = fnt.d->engineForScript(QChar::Script_Common);
QGlyphLayoutArray<1> ellipsisGlyph;
{
@ -2866,8 +2867,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end,
int clusterStart = -1;
int clusterLength = 0;
if (si->analysis.script != QUnicodeTables::Common &&
si->analysis.script != QUnicodeTables::Greek) {
if (si->analysis.script != QChar::Script_Common &&
si->analysis.script != QChar::Script_Greek) {
if (glyph_pos == -1)
return si->position + end;
else {

View File

@ -217,8 +217,8 @@ QSupportedWritingSystems QBasicFontDatabase::determineWritingSystemsFromTrueType
static inline bool scriptRequiresOpenType(int script)
{
return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
|| script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
}
void QBasicFontDatabase::populateFontDatabase()
@ -242,7 +242,7 @@ void QBasicFontDatabase::populateFontDatabase()
}
}
QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *usrPtr)
QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Script script, void *usrPtr)
{
QFontEngineFT *engine;
FontFile *fontfile = static_cast<FontFile *> (usrPtr);
@ -337,7 +337,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QByteArray &fontData, qreal pi
return fe;
}
QStringList QBasicFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
QStringList QBasicFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
Q_UNUSED(family);
Q_UNUSED(style);

View File

@ -58,9 +58,9 @@ class QBasicFontDatabase : public QPlatformFontDatabase
{
public:
void populateFontDatabase();
QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
void releaseHandle(void *handle);

View File

@ -75,10 +75,11 @@ static inline bool requiresOpenType(int writingSystem)
return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
|| writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
}
static inline bool scriptRequiresOpenType(int script)
{
return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
|| script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
}
static int getFCWeight(int fc_weight)
@ -97,14 +98,17 @@ static int getFCWeight(int fc_weight)
}
static const char *specialLanguages[] = {
"en", // Common
"", // Unknown
"", // Inherited
"", // Common
"en", // Latin
"el", // Greek
"ru", // Cyrillic
"hy", // Armenian
"he", // Hebrew
"ar", // Arabic
"syr", // Syriac
"div", // Thaana
"dv", // Thaana
"hi", // Devanagari
"bn", // Bengali
"pa", // Gurmukhi
@ -121,45 +125,85 @@ static const char *specialLanguages[] = {
"my", // Myanmar
"ka", // Georgian
"ko", // Hangul
"", // Ogham
"", // Runic
"am", // Ethiopic
"chr", // Cherokee
"cr", // CanadianAboriginal
"sga", // Ogham
"non", // Runic
"km", // Khmer
"" // N'Ko
"mn", // Mongolian
"ja", // Hiragana
"ja", // Katakana
"zh", // Bopomofo
"zh", // Han
"ii", // Yi
"ett", // OldItalic
"got", // Gothic
"en", // Deseret
"fil", // Tagalog
"hnn", // Hanunoo
"bku", // Buhid
"tbw", // Tagbanwa
"cop", // Coptic
"lif", // Limbu
"tdd", // TaiLe
"grc", // LinearB
"uga", // Ugaritic
"en", // Shavian
"so", // Osmanya
"grc", // Cypriot
"", // Braille
"bug", // Buginese
"khb", // NewTaiLue
"cu", // Glagolitic
"shi", // Tifinagh
"syl", // SylotiNagri
"peo", // OldPersian
"pra", // Kharoshthi
"ban", // Balinese
"akk", // Cuneiform
"phn", // Phoenician
"lzh", // PhagsPa
"man", // Nko
"su", // Sundanese
"lep", // Lepcha
"sat", // OlChiki
"vai", // Vai
"saz", // Saurashtra
"eky", // KayahLi
"rej", // Rejang
"xlc", // Lycian
"xcr", // Carian
"xld", // Lydian
"cjm", // Cham
"nod", // TaiTham
"blt", // TaiViet
"ae", // Avestan
"egy", // EgyptianHieroglyphs
"smp", // Samaritan
"lis", // Lisu
"bax", // Bamum
"jv", // Javanese
"mni", // MeeteiMayek
"arc", // ImperialAramaic
"xsa", // OldSouthArabian
"xpr", // InscriptionalParthian
"pal", // InscriptionalPahlavi
"otk", // OldTurkic
"bh", // Kaithi
"bbc", // Batak
"pra", // Brahmi
"myz", // Mandaic
"ccp", // Chakma
"xmr", // MeroiticCursive
"xmr", // MeroiticHieroglyphs
"hmd", // Miao
"sa", // Sharada
"srb", // SoraSompeng
"doi" // Takri
};
enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
static const ushort specialChars[] = {
0, // English
0, // Greek
0, // Cyrillic
0, // Armenian
0, // Hebrew
0, // Arabic
0, // Syriac
0, // Thaana
0, // Devanagari
0, // Bengali
0, // Gurmukhi
0, // Gujarati
0, // Oriya
0, // Tamil
0xc15, // Telugu
0xc95, // Kannada
0xd15, // Malayalam
0xd9a, // Sinhala
0, // Thai
0, // Lao
0, // Tibetan
0x1000, // Myanmar
0, // Georgian
0, // Hangul
0x1681, // Ogham
0x16a0, // Runic
0, // Khmer
0x7ca // N'Ko
};
enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
// this could become a list of all languages used for each writing
// system, instead of using the single most common language.
static const char *languageForWritingSystem[] = {
@ -194,9 +238,9 @@ static const char *languageForWritingSystem[] = {
"ko", // Korean
"vi", // Vietnamese
0, // Symbol
0, // Ogham
0, // Runic
0 // N'Ko
"sga", // Ogham
"non", // Runic
"man" // N'Ko
};
enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
@ -477,13 +521,12 @@ void QFontconfigDatabase::populateFontDatabase()
// QApplication::setFont(font);
}
QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine,
QUnicodeTables::Script script)
QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
{
return new QFontEngineMultiFontConfig(fontEngine, script);
}
QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr)
QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QChar::Script script, void *usrPtr)
{
if (!usrPtr)
return 0;
@ -601,7 +644,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
return engine;
}
QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
QStringList fallbackFamilies;
FcPattern *pattern = FcPatternCreate();
@ -621,8 +664,8 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const
slant_value = FC_SLANT_OBLIQUE;
FcPatternAddInteger(pattern, FC_SLANT, slant_value);
if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') {
Q_ASSERT(script < QUnicodeTables::ScriptCount);
Q_ASSERT(uint(script) < SpecialLanguageCount);
if (*specialLanguages[script] != '\0') {
FcLangSet *ls = FcLangSetCreate();
FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
FcPatternAddLangSet(pattern, FC_LANG, ls);

View File

@ -51,9 +51,9 @@ class QFontconfigDatabase : public QBasicFontDatabase
{
public:
void populateFontDatabase();
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script);
QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
QString resolveFontFamilyAlias(const QString &family) const;
QFont defaultFont() const;

View File

@ -85,9 +85,9 @@ static const char *languageForWritingSystem[] = {
"ko", // Korean
"vi", // Vietnamese
0, // Symbol
0, // Ogham
0, // Runic
0 // N'Ko
"sga", // Ogham
"non", // Runic
"man" // N'Ko
};
enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
@ -325,7 +325,7 @@ void QCoreTextFontDatabase::releaseHandle(void *handle)
CFRelease(CTFontDescriptorRef(handle));
}
QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr)
QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, QChar::Script script, void *usrPtr)
{
Q_UNUSED(script);
@ -375,7 +375,7 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QByteArray &fontData, qreal
return fontEngine;
}
QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
Q_UNUSED(family);
Q_UNUSED(style);

View File

@ -52,9 +52,9 @@ public:
QCoreTextFontDatabase();
~QCoreTextFontDatabase();
void populateFontDatabase();
QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
#ifndef Q_OS_IOS
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
#endif

View File

@ -1132,9 +1132,7 @@ QWindowsFontDatabase::~QWindowsFontDatabase()
removeApplicationFonts();
}
QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef,
QUnicodeTables::Script script,
void *handle)
QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle)
{
QFontEngine *fe = QWindowsFontDatabase::createEngine(script, fontDef,
0, QWindowsContext::instance()->defaultDPI(), false,
@ -1187,7 +1185,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
request.styleStrategy = QFont::NoFontMerging | QFont::PreferMatch;
request.hintingPreference = hintingPreference;
fontEngine = QWindowsFontDatabase::createEngine(QUnicodeTables::Common, request, 0,
fontEngine = QWindowsFontDatabase::createEngine(QChar::Script_Common, request, 0,
QWindowsContext::instance()->defaultDPI(), false, QStringList(),
m_fontEngineData);
@ -1300,7 +1298,7 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal
return fontEngine;
}
QStringList QWindowsFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
QStringList result = QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script);
if (!result.isEmpty())
@ -1538,8 +1536,8 @@ HFONT QWindowsFontDatabase::systemFont()
static inline bool scriptRequiresOpenType(int script)
{
return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
|| script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
}
static const char *other_tryFonts[] = {
@ -1850,7 +1848,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(int script, const QFontDef &requ
directWriteFont->Release();
#endif
if(script == QUnicodeTables::Common
if (script == QChar::Script_Common
&& !(request.styleStrategy & QFont::NoFontMerging)) {
QFontDatabase db;
if (!db.writingSystems(request.family).contains(QFontDatabase::Symbol)) {

View File

@ -78,9 +78,9 @@ public:
~QWindowsFontDatabase();
virtual void populateFontDatabase();
virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
virtual QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
virtual void releaseHandle(void *handle);
virtual QString fontDir() const;

View File

@ -362,7 +362,7 @@ void QWindowsFontDatabaseFT::populate(const QString &family)
ReleaseDC(0, dummy);
}
QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle)
QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle)
{
QFontEngine *fe = QBasicFontDatabase::fontEngine(fontDef, script, handle);
if (QWindowsContext::verboseFonts)
@ -430,9 +430,9 @@ static const char *kr_tryFonts[] = {
static const char **tryFonts = 0;
QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
if(script == QUnicodeTables::Common) {
if (script == QChar::Script_Common) {
// && !(request.styleStrategy & QFont::NoFontMerging)) {
QFontDatabase db;
if (!db.writingSystems(family).contains(QFontDatabase::Symbol)) {
@ -518,8 +518,8 @@ HFONT QWindowsFontDatabaseFT::systemFont()
static inline bool scriptRequiresOpenType(int script)
{
return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
|| script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
}
static inline int verticalDPI()

View File

@ -52,10 +52,10 @@ class QWindowsFontDatabaseFT : public QBasicFontDatabase
{
public:
void populateFontDatabase();
QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle);
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
virtual QString fontDir() const;
virtual QFont defaultFont() const;

View File

@ -66,7 +66,6 @@
#include <QtCore/QThreadStorage>
#include <QtCore/private/qsystemlibrary_p.h>
#include <QtCore/private/qunicodetables_p.h>
#include <QtCore/QDebug>
#include <limits.h>
@ -1269,7 +1268,7 @@ QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
request.styleStrategy |= QFont::NoFontMerging;
QFontEngine *fontEngine =
QWindowsFontDatabase::createEngine(QUnicodeTables::Common, request, 0,
QWindowsFontDatabase::createEngine(QChar::Script_Common, request, 0,
QWindowsContext::instance()->defaultDPI(),
false,
QStringList(), m_fontEngineData);

View File

@ -709,41 +709,6 @@ void tst_QChar::lineBreakClass()
void tst_QChar::script()
{
QVERIFY(QUnicodeTables::script(0x0020u) == QUnicodeTables::Common);
QVERIFY(QUnicodeTables::script(0x0041u) == QUnicodeTables::Common); // ### Latin
QVERIFY(QUnicodeTables::script(0x0375u) == QUnicodeTables::Greek);
QVERIFY(QUnicodeTables::script(0x0400u) == QUnicodeTables::Cyrillic);
QVERIFY(QUnicodeTables::script(0x0531u) == QUnicodeTables::Armenian);
QVERIFY(QUnicodeTables::script(0x0591u) == QUnicodeTables::Hebrew);
QVERIFY(QUnicodeTables::script(0x0600u) == QUnicodeTables::Arabic);
QVERIFY(QUnicodeTables::script(0x0700u) == QUnicodeTables::Syriac);
QVERIFY(QUnicodeTables::script(0x0780u) == QUnicodeTables::Thaana);
QVERIFY(QUnicodeTables::script(0x07c0u) == QUnicodeTables::Nko);
QVERIFY(QUnicodeTables::script(0x0900u) == QUnicodeTables::Devanagari);
QVERIFY(QUnicodeTables::script(0x0981u) == QUnicodeTables::Bengali);
QVERIFY(QUnicodeTables::script(0x0a01u) == QUnicodeTables::Gurmukhi);
QVERIFY(QUnicodeTables::script(0x0a81u) == QUnicodeTables::Gujarati);
QVERIFY(QUnicodeTables::script(0x0b01u) == QUnicodeTables::Oriya);
QVERIFY(QUnicodeTables::script(0x0b82u) == QUnicodeTables::Tamil);
QVERIFY(QUnicodeTables::script(0x0c01u) == QUnicodeTables::Telugu);
QVERIFY(QUnicodeTables::script(0x0c82u) == QUnicodeTables::Kannada);
QVERIFY(QUnicodeTables::script(0x0d02u) == QUnicodeTables::Malayalam);
QVERIFY(QUnicodeTables::script(0x0d82u) == QUnicodeTables::Sinhala);
QVERIFY(QUnicodeTables::script(0x0e01u) == QUnicodeTables::Thai);
QVERIFY(QUnicodeTables::script(0x0e81u) == QUnicodeTables::Lao);
QVERIFY(QUnicodeTables::script(0x0f00u) == QUnicodeTables::Tibetan);
QVERIFY(QUnicodeTables::script(0x1000u) == QUnicodeTables::Myanmar);
QVERIFY(QUnicodeTables::script(0x10a0u) == QUnicodeTables::Georgian);
QVERIFY(QUnicodeTables::script(0x1100u) == QUnicodeTables::Hangul);
QVERIFY(QUnicodeTables::script(0x1680u) == QUnicodeTables::Ogham);
QVERIFY(QUnicodeTables::script(0x16a0u) == QUnicodeTables::Runic);
QVERIFY(QUnicodeTables::script(0x1780u) == QUnicodeTables::Khmer);
QVERIFY(QUnicodeTables::script(0x200cu) == QUnicodeTables::Inherited);
QVERIFY(QUnicodeTables::script(0x200du) == QUnicodeTables::Inherited);
QVERIFY(QUnicodeTables::script(0x1018au) == QUnicodeTables::Greek);
QVERIFY(QUnicodeTables::script(0x1f130u) == QUnicodeTables::Common);
QVERIFY(QUnicodeTables::script(0xe0100u) == QUnicodeTables::Inherited);
QVERIFY(QChar::script(0x0020u) == QChar::Script_Common);
QVERIFY(QChar::script(0x0041u) == QChar::Script_Latin);
QVERIFY(QChar::script(0x0375u) == QChar::Script_Greek);

View File

@ -281,7 +281,7 @@ void tst_QFontMetrics::inFontUcs4()
}
{
QFontEngine *engine = QFontPrivate::get(font)->engineForScript(QUnicodeTables::Common);
QFontEngine *engine = QFontPrivate::get(font)->engineForScript(QChar::Script_Common);
QGlyphLayout glyphs;
glyphs.numGlyphs = 3;
uint buf[3];

View File

@ -715,10 +715,6 @@ static const char *methods =
"Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4);\n"
"inline LineBreakClass lineBreakClass(QChar ch)\n"
"{ return lineBreakClass(ch.unicode()); }\n"
"\n"
"Q_CORE_EXPORT Script QT_FASTCALL script(uint ucs4);\n"
"inline Script script(QChar ch)\n"
"{ return script(ch.unicode()); }\n"
"\n";
static const int SizeOfPropertiesStruct = 20;
@ -1961,42 +1957,6 @@ static void readBlocks()
}
#endif
static QList<QByteArray> scriptNames;
static QList<int> scriptList;
static const char *specialScripts[] = {
"Common",
"Greek",
"Cyrillic",
"Armenian",
"Hebrew",
"Arabic",
"Syriac",
"Thaana",
"Devanagari",
"Bengali",
"Gurmukhi",
"Gujarati",
"Oriya",
"Tamil",
"Telugu",
"Kannada",
"Malayalam",
"Sinhala",
"Thai",
"Lao",
"Tibetan",
"Myanmar",
"Georgian",
"Hangul",
"Ogham",
"Runic",
"Khmer",
"Nko",
"Inherited"
};
enum { specialScriptsCount = sizeof(specialScripts) / sizeof(const char *) };
static void readScripts()
{
qDebug("Reading Scripts.txt");
@ -2007,13 +1967,6 @@ static void readScripts()
f.open(QFile::ReadOnly);
int scriptsCount = specialScriptsCount;
// ### preserve the old ordering (temporary)
for (int i = 0; i < specialScriptsCount; ++i) {
scriptNames.append(specialScripts[i]);
scriptList.append(i);
}
while (!f.atEnd()) {
QByteArray line = f.readLine();
line.resize(line.size() - 1);
@ -2049,20 +2002,6 @@ static void readScripts()
qFatal("Unhandled script property value: %s", scriptName.constData());
QChar::Script script = scriptMap.value(scriptName, QChar::Script_Unknown);
int scriptIndex = scriptNames.indexOf(scriptName);
if (scriptIndex == -1) {
scriptIndex = scriptNames.size();
scriptNames.append(scriptName);
// is the script alias for 'Common'?
int s = specialScriptsCount;
while (--s > 0) {
if (scriptName == specialScripts[s])
break;
}
scriptList.append(s > 0 ? scriptsCount++ : 0);
}
for (int codepoint = first; codepoint <= last; ++codepoint) {
UnicodeData &ud = UnicodeData::valueRef(codepoint);
ud.p.script = script;
@ -2070,36 +2009,6 @@ static void readScripts()
}
}
static QByteArray createScriptEnumDeclaration()
{
QByteArray declaration;
declaration += "// See http://www.unicode.org/reports/tr24/tr24-5.html\n";
declaration += "enum Script {\n Common";
// output the ones with special processing first
for (int i = 1; i < scriptNames.size(); ++i) {
if (scriptList.at(i) == 0)
continue;
declaration += ",\n ";
declaration += scriptNames.at(i);
}
declaration += ",\n ScriptCount = Inherited";
// output the ones that are an alias for 'Common'
for (int i = 1; i < scriptNames.size(); ++i) {
if (scriptList.at(i) != 0)
continue;
declaration += ",\n ";
declaration += scriptNames.at(i);
declaration += " = Common";
}
declaration += "\n};\n\n";
return declaration;
}
#if 0
static void dump(int from, int to)
{
@ -2398,43 +2307,6 @@ static QByteArray createPropertyInfo()
"{\n"
" return (LineBreakClass)qGetProp(ucs4)->lineBreakClass;\n"
"}\n"
"\n"
"Q_CORE_EXPORT Script QT_FASTCALL script(uint ucs4)\n"
"{\n"
" switch (qGetProp(ucs4)->script) {\n"
" case QChar::Script_Inherited: return Inherited;\n"
" case QChar::Script_Common: return Common;\n"
" case QChar::Script_Arabic: return Arabic;\n"
" case QChar::Script_Armenian: return Armenian;\n"
" case QChar::Script_Bengali: return Bengali;\n"
" case QChar::Script_Cyrillic: return Cyrillic;\n"
" case QChar::Script_Devanagari: return Devanagari;\n"
" case QChar::Script_Georgian: return Georgian;\n"
" case QChar::Script_Greek: return Greek;\n"
" case QChar::Script_Gujarati: return Gujarati;\n"
" case QChar::Script_Gurmukhi: return Gurmukhi;\n"
" case QChar::Script_Hangul: return Hangul;\n"
" case QChar::Script_Hebrew: return Hebrew;\n"
" case QChar::Script_Kannada: return Kannada;\n"
" case QChar::Script_Khmer: return Khmer;\n"
" case QChar::Script_Lao: return Lao;\n"
" case QChar::Script_Malayalam: return Malayalam;\n"
" case QChar::Script_Myanmar: return Myanmar;\n"
" case QChar::Script_Ogham: return Ogham;\n"
" case QChar::Script_Oriya: return Oriya;\n"
" case QChar::Script_Runic: return Runic;\n"
" case QChar::Script_Sinhala: return Sinhala;\n"
" case QChar::Script_Syriac: return Syriac;\n"
" case QChar::Script_Tamil: return Tamil;\n"
" case QChar::Script_Telugu: return Telugu;\n"
" case QChar::Script_Thaana: return Thaana;\n"
" case QChar::Script_Thai: return Thai;\n"
" case QChar::Script_Tibetan: return Tibetan;\n"
" case QChar::Script_Nko: return Nko;\n"
" default: break;\n"
" };\n"
" return Common;\n"
"}\n"
"\n";
return out;
@ -2915,7 +2787,6 @@ int main(int, char **)
QByteArray compositions = createCompositionInfo();
QByteArray ligatures = createLigatureInfo();
QByteArray normalizationCorrections = createNormalizationCorrections();
QByteArray scriptEnumDeclaration = createScriptEnumDeclaration();
QByteArray header =
"/****************************************************************************\n"
@ -3006,7 +2877,6 @@ int main(int, char **)
f.write("#define UNICODE_DATA_VERSION "DATA_VERSION_STR"\n\n");
f.write("namespace QUnicodeTables {\n\n");
f.write(property_string);
f.write(scriptEnumDeclaration);
f.write(grapheme_break_class_string);
f.write(word_break_class_string);
f.write(sentence_break_class_string);