Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
73d269db by wurstsalat at 2022-05-26T14:33:08+02:00
imprv: Avatars: Render emojis correctly

Fixes: #10905

- - - - -


2 changed files:

- gajim/gtk/avatar.py
- gajim/gtk/emoji_data.py


Changes:

=====================================
gajim/gtk/avatar.py
=====================================
@@ -38,6 +38,8 @@
 from gajim.common.const import StyleAttr
 
 from .const import DEFAULT_WORKSPACE_COLOR
+from .emoji_data import is_emoji
+from .emoji_data import get_emoji_font
 from .util import load_icon_surface
 from .util import load_pixbuf
 from .util import text_to_color
@@ -79,7 +81,11 @@ def generate_avatar(letters: str,
     context.fill()
 
     # Draw letters
-    context.select_font_face('sans-serif',
+    if is_emoji(letters):
+        font_face = get_emoji_font()
+    else:
+        font_face = 'sans-serif'
+    context.select_font_face(font_face,
                              cairo.FontSlant.NORMAL,
                              cairo.FontWeight.NORMAL)
     context.set_font_size(font_size)


=====================================
gajim/gtk/emoji_data.py
=====================================
@@ -17,6 +17,7 @@
 from typing import Optional
 
 import re
+import sys
 import weakref
 from enum import IntEnum
 from collections import OrderedDict
@@ -61,6 +62,12 @@ def get_emoji_pixbuf(codepoints: str) -> 
Optional[GdkPixbuf.Pixbuf]:
     return pixbuf
 
 
+def get_emoji_font() -> str:
+    if sys.platform == 'win32':
+        return 'Segoe UI Emoji'
+    return 'Noto Color Emoji'
+
+
 class EmojiData(OrderedDict):
     def __getitem__(self, key):
         try:



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/73d269db1a3a72a5a4b91c9d24b35a3c2f9fd927

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/73d269db1a3a72a5a4b91c9d24b35a3c2f9fd927
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to