Skip to content

Commit

Permalink
Merge pull request #15 from GaZaTu/feature/system-emoji-font-override
Browse files Browse the repository at this point in the history
add setting to override the emoji font
  • Loading branch information
GaZaTu authored Dec 16, 2023
2 parents 901acdf + 48f2cff commit f6b90e7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ saveKaomojiInMRU=false
scaleFactor=
; `true` = Only skin tone neutral emojis are visible (hands for example)
skinTonesDisabled=false
; `not empty` = Use this (for example: Noto Color Emoji) instead of your system font to display emojis
; (requires useSystemEmojiFont=true)
systemEmojiFontOverride=
; `true` = Use your system emoji font instead of the bundled Twemoji images to display emojis
; (requires IMF restart)
useSystemEmojiFont=false
Expand Down
5 changes: 5 additions & 0 deletions src/EmojiLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ void EmojiLabel::setEmoji(const Emoji& emoji, int w, int h) {
QFont textFont = font();
textFont.setPixelSize(w);

std::string fontOverride = _settings.systemEmojiFontOverride();
if (!fontOverride.empty()) {
textFont.setFamily(QString::fromStdString(fontOverride));
}

if (_settings.useSystemEmojiFontWidthHeuristics()) {
if (defaultEmojiWidth == 0) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
Expand Down
13 changes: 12 additions & 1 deletion src/EmojiPickerSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void EmojiPickerSettings::writeDefaultsToDisk() {
s.closeAfterFirstInput(s.closeAfterFirstInput());
s.useSystemEmojiFont(s.useSystemEmojiFont());
s.useSystemEmojiFontWidthHeuristics(s.useSystemEmojiFontWidthHeuristics());
s.systemEmojiFontOverride(s.systemEmojiFontOverride());
s.scaleFactor(s.scaleFactor());
s.saveKaomojiInMRU(s.saveKaomojiInMRU());
s.customHotKeys(s.customHotKeys());
Expand Down Expand Up @@ -186,16 +187,26 @@ void EmojiPickerSettings::useSystemEmojiFontWidthHeuristics(bool useSystemEmojiF
setValue("useSystemEmojiFontWidthHeuristics", useSystemEmojiFontWidthHeuristics);
}

std::string EmojiPickerSettings::systemEmojiFontOverride() const {
return value("systemEmojiFontOverride", "").toString().toStdString();
}

void EmojiPickerSettings::systemEmojiFontOverride(const std::string& systemEmojiFontOverride) {
setValue("systemEmojiFontOverride", QString::fromStdString(systemEmojiFontOverride));
}

std::string EmojiPickerSettings::scaleFactor() const {
return value("scaleFactor", "").toString().toStdString();
}
void EmojiPickerSettings::scaleFactor(std::string scaleFactor) {

void EmojiPickerSettings::scaleFactor(const std::string& scaleFactor) {
setValue("scaleFactor", QString::fromStdString(scaleFactor));
}

bool EmojiPickerSettings::saveKaomojiInMRU() const {
return value("saveKaomojiInMRU", false).toBool();
}

void EmojiPickerSettings::saveKaomojiInMRU(bool saveKaomojiInMRU) {
setValue("saveKaomojiInMRU", saveKaomojiInMRU);
}
Expand Down
5 changes: 4 additions & 1 deletion src/EmojiPickerSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ class EmojiPickerSettings : public QSettings {
bool useSystemEmojiFontWidthHeuristics() const;
void useSystemEmojiFontWidthHeuristics(bool useSystemEmojiFontWidthHeuristics);

std::string systemEmojiFontOverride() const;
void systemEmojiFontOverride(const std::string& systemEmojiFontOverride);

std::string scaleFactor() const;
void scaleFactor(std::string scaleFactor);
void scaleFactor(const std::string& scaleFactor);

bool saveKaomojiInMRU() const;
void saveKaomojiInMRU(bool saveKaomojiInMRU);
Expand Down

0 comments on commit f6b90e7

Please sign in to comment.