Added an optional feature to show bigger emoji-only messages with 3 or less emoji

This commit is contained in:
lkito 2020-05-19 23:04:38 +04:00
parent bdf1147a80
commit d8b89e2ef0
8 changed files with 71 additions and 19 deletions

View file

@ -51,6 +51,14 @@ utils::localUser()
return QString::fromStdString(http::client()->user_id().to_string());
}
bool
utils::codepointIsEmoji(uint code)
{
// TODO: Be more precise here.
return (code >= 0x2600 && code <= 0x27bf) || (code >= 0x1f300 && code <= 0x1f3ff) ||
(code >= 0x1f000 && code <= 0x1faff);
}
QString
utils::replaceEmoji(const QString &body)
{
@ -63,9 +71,7 @@ utils::replaceEmoji(const QString &body)
bool insideFontBlock = false;
for (auto &code : utf32_string) {
// TODO: Be more precise here.
if ((code >= 0x2600 && code <= 0x27bf) || (code >= 0x1f300 && code <= 0x1f3ff) ||
(code >= 0x1f000 && code <= 0x1faff)) {
if (utils::codepointIsEmoji(code)) {
if (!insideFontBlock) {
fmtBody += QString("<font face=\"" + userFontFamily + "\">");
insideFontBlock = true;