Decrease code duplication in QFontDatabase-s
Move scriptRequiresOpenType() body right into QFontEngine::supportsScript(), thus centralizing use of this performance cheat. Change-Id: I5f494b086f8f900b631c491f41e9cb800002c0f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>bb10
parent
741737b080
commit
02651060b6
|
|
@ -309,6 +309,14 @@ void *QFontEngine::harfbuzzFace() const
|
|||
|
||||
bool QFontEngine::supportsScript(QChar::Script script) const
|
||||
{
|
||||
// ### TODO: This only works for scripts that require OpenType. More generally
|
||||
// for scripts that do not require OpenType we should just look at the list of
|
||||
// supported writing systems in the font's OS/2 table.
|
||||
if (!((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|
||||
|| script == QChar::Script_Khmer || script == QChar::Script_Nko)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef QT_ENABLE_HARFBUZZ_NG
|
||||
if (useHarfbuzzNG) {
|
||||
bool ret = false;
|
||||
|
|
|
|||
|
|
@ -91,12 +91,6 @@ typedef struct {
|
|||
quint16 stringOffset;
|
||||
} NAME_RECORD;
|
||||
|
||||
static inline bool scriptRequiresOpenType(int script)
|
||||
{
|
||||
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|
||||
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
|
||||
}
|
||||
|
||||
void QBasicFontDatabase::populateFontDatabase()
|
||||
{
|
||||
QString fontpath = fontDir();
|
||||
|
|
@ -137,11 +131,9 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Scri
|
|||
if (engine->invalid()) {
|
||||
delete engine;
|
||||
engine = 0;
|
||||
} else if (scriptRequiresOpenType(script)) {
|
||||
if (!engine->supportsScript(script)) {
|
||||
delete engine;
|
||||
engine = 0;
|
||||
}
|
||||
} else if (!engine->supportsScript(script)) {
|
||||
delete engine;
|
||||
engine = 0;
|
||||
}
|
||||
|
||||
return engine;
|
||||
|
|
|
|||
|
|
@ -69,12 +69,6 @@ static inline bool requiresOpenType(int writingSystem)
|
|||
|| writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
|
||||
}
|
||||
|
||||
static inline bool scriptRequiresOpenType(int script)
|
||||
{
|
||||
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|
||||
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
|
||||
}
|
||||
|
||||
static int getFCWeight(int fc_weight)
|
||||
{
|
||||
int qtweight = QFont::Black;
|
||||
|
|
@ -602,11 +596,9 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QChar::Script sc
|
|||
if (engine->invalid()) {
|
||||
delete engine;
|
||||
engine = 0;
|
||||
} else if (scriptRequiresOpenType(script)) {
|
||||
if (!engine->supportsScript(script)) {
|
||||
delete engine;
|
||||
engine = 0;
|
||||
}
|
||||
} else if (!engine->supportsScript(script)) {
|
||||
delete engine;
|
||||
engine = 0;
|
||||
}
|
||||
|
||||
return engine;
|
||||
|
|
|
|||
|
|
@ -1407,12 +1407,6 @@ HFONT QWindowsFontDatabase::systemFont()
|
|||
|
||||
// Creation functions
|
||||
|
||||
static inline bool scriptRequiresOpenType(int script)
|
||||
{
|
||||
return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|
||||
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
|
||||
}
|
||||
|
||||
static const char *other_tryFonts[] = {
|
||||
"Arial",
|
||||
"MS UI Gothic",
|
||||
|
|
@ -1763,15 +1757,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(int script, const QFontDef &requ
|
|||
few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
|
||||
|
||||
// Also check for OpenType tables when using complex scripts
|
||||
// ### TODO: This only works for scripts that require OpenType. More generally
|
||||
// for scripts that do not require OpenType we should just look at the list of
|
||||
// supported writing systems in the font's OS/2 table.
|
||||
if (scriptRequiresOpenType(script)) {
|
||||
if (!few->supportsScript(QChar::Script(script))) {
|
||||
qWarning(" OpenType support missing for script\n");
|
||||
delete few;
|
||||
return 0;
|
||||
}
|
||||
if (!few->supportsScript(QChar::Script(script))) {
|
||||
qWarning(" OpenType support missing for script\n");
|
||||
delete few;
|
||||
return 0;
|
||||
}
|
||||
|
||||
few->initFontInfo(request, fontHdc, dpi);
|
||||
|
|
|
|||
Loading…
Reference in New Issue