Fix Qt not showing up emoji by handling emoji font family
This commit is contained in:
parent
a19a7d36f9
commit
a44bfe9ca5
@ -38,7 +38,7 @@ BuildRequires: pkgconfig(libsystemd)
|
||||
Name: qt6-qtbase
|
||||
Summary: Qt6 - QtBase components
|
||||
Version: 6.6.0
|
||||
Release: 4%{?dist}
|
||||
Release: 5%{?dist}
|
||||
|
||||
License: LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
Url: http://qt-project.org/
|
||||
@ -90,6 +90,8 @@ Patch58: qtbase-libglvnd.patch
|
||||
# fix FTBS against libxkbcommon 1.6.0
|
||||
Patch59: qtbase-libxkbcommon-1.6.0.patch
|
||||
|
||||
# Bug 1954359 - Many emoji don't show up in Qt apps because qt does not handle 'emoji' font family
|
||||
Patch60: qtbase-cache-emoji-font.patch
|
||||
|
||||
%if 0%{?fedora} < 39
|
||||
# Latest QGnomePlatform needs to be specified to be used
|
||||
@ -834,6 +836,9 @@ make check -k ||:
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Nov 07 2023 Jan Grulich <jgrulich@redhat.com> - 6.6.0-5
|
||||
- Fix Qt not showing up emoji by handling emoji font family
|
||||
|
||||
* Mon Nov 06 2023 Jan Grulich <jgrulich@redhat.com> - 6.6.0-4
|
||||
- Upstream backports
|
||||
- a11y - fix race condition on atspi startup on Wayland
|
||||
|
85
qtbase-cache-emoji-font.patch
Normal file
85
qtbase-cache-emoji-font.patch
Normal file
@ -0,0 +1,85 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user