Adds primitive support for emoji fonts.
This commit is contained in:
parent
696660b243
commit
7f0143b874
|
@ -1,5 +1,10 @@
|
|||
# Kristall Changelog
|
||||
|
||||
## 0.4 - Improved user experience
|
||||
* Basic Emoji rendering support using OpenMoji
|
||||
*
|
||||
*
|
||||
|
||||
## 0.3 - TLS and security
|
||||
* Adds support for transient client certificates
|
||||
* Adds support for permanent client certificates
|
||||
|
|
|
@ -265,7 +265,7 @@ bool DocumentStyle::load(QSettings &settings)
|
|||
margin = settings.value("margins").toDouble();
|
||||
theme = Theme(settings.value("theme").toInt());
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
theme = Theme(settings.value("theme", int(theme)).toInt());
|
||||
|
@ -318,10 +318,32 @@ bool DocumentStyle::load(QSettings &settings)
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
// Patch font lists to allow improved emoji display:
|
||||
|
||||
QStringList emojiFonts = { "Apple Color Emoji", "Segoe UI Emoji", "Twitter Color Emoji", "Noto Color Emoji", "JoyPixels" };
|
||||
|
||||
QFont::insertSubstitutions(h1_font.family(), emojiFonts);
|
||||
QFont::insertSubstitutions(h2_font.family(), emojiFonts);
|
||||
QFont::insertSubstitutions(h3_font.family(), emojiFonts);
|
||||
QFont::insertSubstitutions(standard_font.family(), emojiFonts);
|
||||
QFont::insertSubstitutions(preformatted_font.family(), emojiFonts);
|
||||
|
||||
// from docs:
|
||||
// > After substituting a font, you must trigger the updating of the font by destroying and re-creating all QFont objects.
|
||||
h1_font.fromString(h1_font.toString());
|
||||
h2_font.fromString(h2_font.toString());
|
||||
h3_font.fromString(h3_font.toString());
|
||||
standard_font.fromString(standard_font.toString());
|
||||
preformatted_font.fromString(preformatted_font.toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DocumentStyle DocumentStyle::derive(const QUrl &url) const
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>fonts/OpenMoji-Color.ttf</file>
|
||||
<file>fonts/NotoColorEmoji.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
Binary file not shown.
Binary file not shown.
|
@ -51,10 +51,10 @@ macx {
|
|||
# Homebrew include paths
|
||||
INCLUDEPATH += /usr/local/opt/qt/include
|
||||
LIBS += -L/usr/local/opt/qt/lib
|
||||
|
||||
|
||||
INCLUDEPATH += /usr/local/opt/openssl/include
|
||||
LIBS += -L/usr/local/opt/openssl/lib
|
||||
|
||||
|
||||
ICON = icons/AppIcon.icns
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
RESOURCES += \
|
||||
./fonts.qrc \
|
||||
../lib/BreezeStyleSheets/breeze.qrc \
|
||||
builtins.qrc \
|
||||
icons.qrc
|
||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -7,6 +7,7 @@
|
|||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QStandardPaths>
|
||||
#include <QFontDatabase>
|
||||
#include <cassert>
|
||||
|
||||
ProtocolSetup kristall::protocols;
|
||||
|
@ -50,6 +51,36 @@ static QDir derive_dir(QDir const & parent, QString subdir)
|
|||
return child;
|
||||
}
|
||||
|
||||
static void addEmojiSubstitutions()
|
||||
{
|
||||
QFontDatabase db;
|
||||
|
||||
auto const families = db.families();
|
||||
|
||||
// Provide OpenMoji font for a safe fallback
|
||||
QFontDatabase::addApplicationFont(":/fonts/OpenMoji-Color.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/NotoColorEmoji.ttf");
|
||||
|
||||
QStringList emojiFonts = {
|
||||
// Use system fonts on windows/mac
|
||||
"Apple Color Emoji",
|
||||
"Segoe UI Emoji",
|
||||
|
||||
// Provide common fonts as a fallback:
|
||||
// "Noto Color Emoji", // this font seems to replace a lot of text characters?
|
||||
// "JoyPixels", // this font seems to replace a lot of text characters?
|
||||
|
||||
// Built-in font fallback
|
||||
"OpenMoji",
|
||||
};
|
||||
|
||||
for(auto const & family: families)
|
||||
{
|
||||
auto current = QFont::substitutes(family);
|
||||
current << emojiFonts;
|
||||
QFont::insertSubstitutions(family, current);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -61,6 +92,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
kristall::clipboard = app.clipboard();
|
||||
|
||||
addEmojiSubstitutions();
|
||||
|
||||
QCommandLineParser cli_parser;
|
||||
cli_parser.addVersionOption();
|
||||
cli_parser.addHelpOption();
|
||||
|
@ -261,7 +294,6 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
app_settings.endGroup();
|
||||
|
||||
|
||||
w.show();
|
||||
|
||||
int exit_code = app.exec();
|
||||
|
|
|
@ -97,6 +97,7 @@ void GopherClient::on_finished()
|
|||
{
|
||||
if(not was_cancelled)
|
||||
{
|
||||
this->on_readRead();
|
||||
emit this->requestComplete(this->body, mime);
|
||||
was_cancelled = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue