return (preference >= other.preference);
}
-class QFontDatabasePrivate
-{
-public:
-#if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)
- QString systemLang;
-#endif
- QVector<QtFontFamily> families;
-};
+typedef QVector<QtFontFamily> QtFontFamilyList;
-Q_GLOBAL_STATIC(QFontDatabasePrivate, qGlobalFontDatabase)
+Q_GLOBAL_STATIC(QtFontFamilyList, qGlobalFontDatabase)
Q_GLOBAL_STATIC(QMutex, qGlobalFontDatabaseMutex)
/*!
}
if (result.isEmpty()) {
- foreach (const QtFontFamily &fontfamily, qGlobalFontDatabase()->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(family, Qt::CaseInsensitive) != 0) {
continue;
}
{
QMutexLocker locker(qGlobalFontDatabaseMutex());
- d = qGlobalFontDatabase();
- if (!d || d->families.size() > 0)
+ QtFontFamilyList* db = qGlobalFontDatabase();
+ if (!db || db->size() > 0)
return;
#ifndef QT_NO_FONTCONFIG
"QFontDatabase", "New scripts have been added.");
FcFontSet *fonts;
-
+ FcObjectSet *os = FcObjectSetCreate();
FcPattern *pattern = FcPatternCreate();
- FcDefaultSubstitute(pattern);
- FcChar8 *lang = nullptr;
- if (FcPatternGetString(pattern, FC_LANG, 0, &lang) == FcResultMatch)
- d->systemLang = QString::fromUtf8((const char *) lang);
- FcPatternDestroy(pattern);
-
- {
- FcObjectSet *os = FcObjectSetCreate();
- FcPattern *pattern = FcPatternCreate();
- for (qint16 i = 0; i < PatternPropertiesTblSize; i++) {
- FcObjectSetAdd(os, PatternPropertiesTbl[i]);
- }
- fonts = FcFontList(0, pattern, os);
- FcObjectSetDestroy(os);
- FcPatternDestroy(pattern);
+ for (qint16 i = 0; i < PatternPropertiesTblSize; i++) {
+ FcObjectSetAdd(os, PatternPropertiesTbl[i]);
}
+ fonts = FcFontList(0, pattern, os);
+ FcObjectSetDestroy(os);
+ FcPatternDestroy(pattern);
for (int i = 0; i < fonts->nfont; i++) {
FcChar8 *family_value = nullptr;
fontfamily.preference += 800;
}
- d->families.append(fontfamily);
+ db->append(fontfamily);
}
FcFontSetDestroy(fonts);
- qStableSort(d->families);
+ qStableSort(db->begin(), db->end());
#ifdef QFONTDATABASE_DEBUG
FD_DEBUG("QFontDatabase: loaded FontConfig: %d ms", int(elapsedtimer.elapsed()));
{
QStringList result;
QMap<QString,QStringList> familieswithfoundry;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
familieswithfoundry[fontfamily.family].append(fontfamily.foundry);
}
foreach (const QString &family, familieswithfoundry.keys()) {
parseFontName(family, parsedfoundry, parsedfamily);
QStringList result;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)) {
continue;
parseFontName(family, parsedfoundry, parsedfamily);
bool result = false;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| (!style.isEmpty() && !isStyleMatch(fontfamily.style, style))) {
parseFontName(family, parsedfoundry, parsedfamily);
bool result = false;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| (!style.isEmpty() && !isStyleMatch(fontfamily.style, style))) {
parseFontName(family, parsedfoundry, parsedfamily);
QList<int> result;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| !isStyleMatch(fontfamily.style, style)) {
parseFontName(family, parsedfoundry, parsedfamily);
QFont result = QApplication::font();
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| !isStyleMatch(fontfamily.style, style)) {
parseFontName(family, parsedfoundry, parsedfamily);
QList<int> result;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| !isStyleMatch(fontfamily.style, style)) {
parseFontName(family, parsedfoundry, parsedfamily);
bool result = false;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| !isStyleMatch(fontfamily.style, style)) {
parseFontName(family, parsedfoundry, parsedfamily);
bool result = false;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| !isStyleMatch(fontfamily.style, style)) {
parseFontName(family, parsedfoundry, parsedfamily);
int result = -1;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(parsedfamily, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)
|| !isStyleMatch(fontfamily.style, style)) {
const QString familyalias = resolveFontFamilyAlias(parsedfamily);
bool result = false;
- foreach (const QtFontFamily &fontfamily, d->families) {
+ const QtFontFamilyList* db = qGlobalFontDatabase();
+ for (int i = 0; i < db->size(); i++) {
+ const QtFontFamily &fontfamily = db->at(i);
if (fontfamily.family.compare(familyalias, Qt::CaseInsensitive) != 0
|| (!parsedfoundry.isEmpty() && fontfamily.foundry.compare(parsedfoundry, Qt::CaseInsensitive) != 0)) {
continue;
QT_END_NAMESPACE
#include "moc_qfontdatabase.h"
-
return fontDef;
}
-// values are from likelySubtags.xml distributed with Unicode CLDR data
-static const char *specialLanguagesTbl[] = {
- "en", // Common
- "ff-gn", // Adlam
- "aho-in", // Ahom
- "hlu-tr", // AnatolianHieroglyphs
- "ar", // Arabic
- "hy", // Armenian
- "ae-ir", // Avestan
- "ban-id", // Balinese
- "bax-cm", // Bamum
- "bsq-lr", // BassaVah
- "bbc-id", // Batak
- "bn", // Bengali
- "sa-in", // Bhaiksuki
- "zh-tw", // Bopomofo
- "pka-in", // Brahmi
- "fr-fr", // Braille
- "bug-id", // Buginese
- "bku-ph", // Buhid
- "en-ca", // CanadianAboriginal
- "xcr-tr", // Carian
- "sq", // CaucasianAlbanian
- "ccp-bd", // Chakma
- "cjm-vn", // Cham
- "chr-us", // Cherokee
- "xco-uz", // Chorasmian
- "cop-eg", // Coptic
- "akk-iq", // Cuneiform
- "grc-cy", // Cypriot
- 0, // CyproMinoan
- "ru", // Cyrillic
- 0, // Deseret
- "hi", // Devanagari
- "dv-mv", // DivesAkuru
- "doi-in", // Dogra
- "fr-fr", // Duployan
- "ar-eg", // EgyptianHieroglyphs
- "sq-al", // Elbasan
- "arc-ir", // Elymaic
- 0, // Ethiopic
- "ka", // Georgian
- "cu-bg", // Glagolitic
- "got-ua", // Gothic
- "sa-in", // Grantha
- "el", // Greek
- "gu", // Gujarati
- "wsg-in", // GunjalaGondi
- "pa", // Gurmukhi
- "zh-tw", // Han
- "ko", // Hangul
- "rhg-mm", // HanifiRohingya
- "hnn-ph", // Hanunoo
- "mis-iq", // Hatran
- "he", // Hebrew
- "ja-jp", // Hiragana
- "arc-ir", // ImperialAramaic
- 0, // Inherited
- "pal-ir", // InscriptionalPahlavi
- "xpr-ir", // InscriptionalParthian
- "jv-id", // Javanese
- "bho-in", // Kaithi
- "kn", // Kannada
- "ja-jp", // Katakana
- "eky-mm", // KayahLi
- "pra-pk", // Kharoshthi
- "zkt-cn", // KhitanSmallScript
- "km", // Khmer
- "sd-in", // Khojki
- "sd-in", // Khudawadi
- "lo", // Lao
- "la", // Latin
- "lep-in", // Lepcha
- "lif", // Limbu
- "lab-gr", // LinearA
- "lab-gr", // LinearB
- "lis-cn", // Lisu
- "xlc-tr", // Lycian
- "xld-tr", // Lydian
- "hi-in", // Mahajani
- "mak-id", // Makasar
- "ml", // Malayalam
- "myz-ir", // Mandaic
- "xmn-cn", // Manichaean
- "bo-cn", // Marchen
- "esg-in", // MasaramGondi
- "mis-ng", // Medefaidrin
- "mni-in", // MeeteiMayek
- 0, // MendeKikakui
- "xmr-sd", // MeroiticCursive
- "xmr-sd", // MeroiticHieroglyphs
- "hmd-cn", // Miao
- "mr-in", // Modi
- "mn", // Mongolian
- "mro-bd", // Mro
- "skr-pk", // Multani
- "my", // Myanmar
- "arc-jo", // Nabataean
- "sa-in", // Nandinagari
- "new-np", // Newa
- "khb-cn", // NewTaiLue
- "nqo-gn", // Nko
- "zhx-cn", // Nushu
- "mww-us", // NyiakengPuachueHmong
- "sga-ie", // Ogham
- "sat-in", // OlChiki
- "hu-hu", // OldHungarian
- "ett-it", // OldItalic
- "ar", // OldNorthArabian
- "kv-ru", // OldPermic
- "peo-ir", // OldPersian
- "sog-uz", // OldSogdian
- "ar", // OldSouthArabian
- "otk-mn", // OldTurkic
- "ug-cn", // OldUyghur
- "or", // Oriya
- "osa-us", // Osage
- "so-so", // Osmanya
- "hnj-la", // PahawhHmong
- "arc-sy", // Palmyrene
- "ctd-mm", // PauCinHau
- "lzh-cn", // PhagsPa
- "phn-lb", // Phoenician
- "pal-cn", // PsalterPahlavi
- "rej-id", // Rejang
- "non-se", // Runic
- "smp-il", // Samaritan
- "saz-in", // Saurashtra
- "sa-in", // Sharada
- "en-gb", // Shavian
- "sa-in", // Siddham
- "ase-us", // SignWriting
- "si", // Sinhala
- "sog-uz", // Sogdian
- "srb-in", // SoraSompeng
- "cmg-mn", // Soyombo
- "su-id", // Sundanese
- "syl-bd", // SylotiNagri
- "syr", // Syriac
- "tl-ph", // Tagalog
- "tbw-ph", // Tagbanwa
- "tdd-cn", // TaiLe
- 0, // TaiTham
- "blt-vn", // TaiViet
- "doi-in", // Takri
- "ta", // Tamil
- "ntm-in", // Tangsa
- "txg-cn", // Tangut
- "te", // Telugu
- "div", // Thaana
- "th", // Thai
- "bo", // Tibetan
- 0, // Tifinagh
- "mai-in", // Tirhuta
- "txo-in", // Toto
- "uga-sy", // Ugaritic
- "vai-lr", // Vai
- "sq-al", // Vithkuqi
- "npp-in", // Wancho
- 0, // WarangCiti
- "ku-ge", // Yezidi
- "yi", // Yi
- "cmg-mn", // ZanabazarSquare
-};
-enum { SpecialLanguageCount = sizeof(specialLanguagesTbl) / sizeof(const char *) };
-
// values obtained via genutf script
static const uint specialCharsTbl[] = {
0x0, // Common
FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
- if (script != QUnicodeTables::Common && specialLanguagesTbl[script]) {
- Q_ASSERT(script < QUnicodeTables::ScriptCount);
- FcLangSet *ls = FcLangSetCreate();
- FcLangSetAdd(ls, (const FcChar8*)specialLanguagesTbl[script]);
- FcPatternDel(pattern, FC_LANG);
- FcPatternAddLangSet(pattern, FC_LANG, ls);
- FcLangSetDestroy(ls);
- }
-
if (!request.styleName.isEmpty()) {
QByteArray cs = request.styleName.toUtf8();
FcPatternAddString(pattern, FC_STYLE, (const FcChar8 *) cs.constData());
return nullptr;
if (script != QUnicodeTables::Common) {
- // skip font if it doesn't support the language we want
- if (specialLanguagesTbl[script]){
- FcLangSet *langSet = 0;
- if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch)
- goto special_char;
- if (FcLangSetHasLang(langSet, (const FcChar8*)specialLanguagesTbl[script]) != FcLangEqual)
- goto special_char;
- }
-special_char:
+ // need to check the charset, as the langset doesn't work for some scripts
if (specialCharsTbl[script]) {
- // need to check the charset, as the langset doesn't work for some scripts
FcCharSet *cs;
if (FcPatternGetCharSet(match, FC_CHARSET, 0, &cs) != FcResultMatch)
return nullptr;