7 Star 0 Fork 0

OpenCloudOS Stream/qt6-qtbase

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qtbase-cache-emoji-font.patch 2.79 KB
一键复制 编辑 原始数据 按行查看 历史
ocs-bot 提交于 2024-05-12 23:47 . update
diff --git a/src/gui/text/unix/qfontconfigdatabase.cpp b/src/gui/text/unix/qfontconfigdatabase.cpp
index 474644b8..f61e6e83 100644
--- a/src/gui/text/unix/qfontconfigdatabase.cpp
+++ b/src/gui/text/unix/qfontconfigdatabase.cpp
@@ -592,6 +592,7 @@ void QFontconfigDatabase::populateFontDatabase()
++f;
}
+ cacheEmojiFontFamily();
//QPA has very lazy population of the font db. We want it to be initialized when
//QApplication is constructed, so that the population procedure can do something like this to
//set the default font
@@ -735,6 +736,9 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont
if (!pattern)
return fallbackFamilies;
+ if (!m_cacheEmojiFontFamily.isEmpty())
+ fallbackFamilies << m_cacheEmojiFontFamily;
+
FcValue value;
value.type = FcTypeString;
const QByteArray cs = family.toUtf8();
@@ -1016,4 +1020,47 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef
engine->glyphFormat = format;
}
+void QFontconfigDatabase::cacheEmojiFontFamily()
+{
+ FcPattern *pattern;
+ pattern = FcPatternCreate();
+
+ FcValue value;
+ value.type = FcTypeString;
+ value.u.s = (const FcChar8 *)"emoji";
+ FcPatternAdd(pattern,FC_FAMILY,value,true);
+
+ FcLangSet *ls = FcLangSetCreate();
+ FcLangSetAdd(ls, (const FcChar8*)"und-zsye");
+ FcPatternAddLangSet(pattern, FC_LANG, ls);
+
+ FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcResult result = FcResultMatch;
+ FcFontSet *fontSet = FcFontSort(nullptr,pattern,FcTrue,nullptr,&result);
+ FcPatternDestroy(pattern);
+
+ if (fontSet) {
+ for (int i = 0; i < fontSet->nfont; i++) {
+ FcChar8 *value = nullptr;
+ if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
+ continue;
+
+ FcLangSet *rls = nullptr;
+ if (FcPatternGetLangSet(fontSet->fonts[i], FC_LANG, 0, &rls) != FcResultMatch)
+ continue;
+
+ if (!FcLangSetContains(rls, ls))
+ continue;
+
+ m_cacheEmojiFontFamily = QString::fromUtf8((const char *)value);
+ break;
+ }
+ FcFontSetDestroy(fontSet);
+ }
+
+ FcLangSetDestroy(ls);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/text/unix/qfontconfigdatabase_p.h b/src/gui/text/unix/qfontconfigdatabase_p.h
index cf15306e..90b94087 100644
--- a/src/gui/text/unix/qfontconfigdatabase_p.h
+++ b/src/gui/text/unix/qfontconfigdatabase_p.h
@@ -37,7 +37,10 @@ public:
QFont defaultFont() const override;
private:
+ void cacheEmojiFontFamily();
void setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const;
+
+ QString m_cacheEmojiFontFamily;
};
QT_END_NAMESPACE
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opencloudos-stream/qt6-qtbase.git
git@gitee.com:opencloudos-stream/qt6-qtbase.git
opencloudos-stream
qt6-qtbase
qt6-qtbase
master

搜索帮助