mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Improve emoji escaping
This commit is contained in:
parent
dc44ac50a3
commit
79e4e2e6e1
1 changed files with 15 additions and 5 deletions
|
@ -39,12 +39,22 @@ utils::replaceEmoji(const QString &body)
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString userFontFamily = settings.value("user/emoji_font_family", "emoji").toString();
|
QString userFontFamily = settings.value("user/emoji_font_family", "emoji").toString();
|
||||||
|
|
||||||
|
bool insideFontBlock = true;
|
||||||
for (auto &code : utf32_string) {
|
for (auto &code : utf32_string) {
|
||||||
// TODO: Be more precise here.
|
// TODO: Be more precise here.
|
||||||
if (code > 9000)
|
if ((code >= 0x2600 && code <= 0x27bf) || (code >= 0x1f300 && code <= 0x1f3ff) ||
|
||||||
fmtBody += QString("<font face=\"" + userFontFamily + "\">") +
|
(code >= 0x1f000 && code <= 0x1f64f) || (code >= 0x1f680 && code <= 0x1f6ff)) {
|
||||||
QString::fromUcs4(&code, 1) + "</font>";
|
if (!insideFontBlock) {
|
||||||
else
|
fmtBody += QString("<font face=\"" + userFontFamily + "\">");
|
||||||
|
insideFontBlock = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (insideFontBlock) {
|
||||||
|
fmtBody += "</font>";
|
||||||
|
insideFontBlock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
fmtBody += QString::fromUcs4(&code, 1);
|
fmtBody += QString::fromUcs4(&code, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue