From 58213ee3e6406cb467b6cfd23cb5fb414630139f Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 8 Aug 2023 12:07:16 +0200 Subject: [PATCH] Display big emoji correctly We already check with a regex if the message only contains emoji so it is safe to hardcode the font family as emoji for these messages. --- src/qml/Component/Timeline/RichLabel.qml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qml/Component/Timeline/RichLabel.qml b/src/qml/Component/Timeline/RichLabel.qml index d41745cbc..ea49943a5 100644 --- a/src/qml/Component/Timeline/RichLabel.qml +++ b/src/qml/Component/Timeline/RichLabel.qml @@ -27,7 +27,12 @@ TextEdit { /** * @brief Regex for detecting a message with a single emoji. */ - readonly property var isEmoji: /^()?(\u00a9|\u00ae|[\u20D0-\u2fff]|[\u3190-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])+(<\/span>)?$/ + readonly property var isEmojiRegex: /^()?(\u00a9|\u00ae|[\u20D0-\u2fff]|[\u3190-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])+(<\/span>)?$/ + + /** + * @brief Whether the message is an emoji + */ + readonly property var isEmoji: isEmojiRegex.test(textMessage) /** * @brief Regex for detecting a message with a spoiler. @@ -85,7 +90,10 @@ a{ color: Kirigami.Theme.textColor selectedTextColor: Kirigami.Theme.highlightedTextColor selectionColor: Kirigami.Theme.highlightColor - font.pointSize: !root.isReply && isEmoji.test(textMessage) ? Kirigami.Theme.defaultFont.pointSize * 4 : Kirigami.Theme.defaultFont.pointSize + font { + pointSize: !root.isReply && root.isEmoji ? Kirigami.Theme.defaultFont.pointSize * 4 : Kirigami.Theme.defaultFont.pointSize + family: root.isEmoji ? 'emoji' : Kirigami.Theme.defaultFont.family + } selectByMouse: !Kirigami.Settings.isMobile readOnly: true wrapMode: Text.Wrap