Daniel Brötzmann pushed to branch emoji-improvements at gajim / gajim
Commits: 9cdd7b08 by André Apitzsch at 2022-09-23T21:10:25+02:00 chore: Flatpak: Update runtime + dependencies
- - - - - d3ea959c by wurstsalat at 2022-09-24T13:08:44+02:00 imprv: Emojis: Extract codepoints for all emoji variants
- - - - - deeded39 by wurstsalat at 2022-09-24T13:08:44+02:00 imprv: Avatars: Use PangoCairo for generate_avatar
Fixes #10960
- - - - - 7a0674b8 by wurstsalat at 2022-09-24T13:08:44+02:00 chore: emoji_data: Remove unused method
- - - - -
8 changed files:
- flatpak/org.gajim.Gajim.Devel.yaml - flatpak/org.gajim.Gajim.yaml - gajim/gajim.py - gajim/gtk/avatar.py - gajim/gtk/emoji_data.py - gajim/gtk/emoji_data.pyi - gajim/gtk/emoji_data_gtk.py - gajim/gtk/workspace_dialog.py
Changes:
===================================== flatpak/org.gajim.Gajim.Devel.yaml ===================================== @@ -1,6 +1,6 @@ app-id: org.gajim.Gajim.Devel runtime: org.gnome.Platform -runtime-version: '42' +runtime-version: '43' sdk: org.gnome.Sdk command: gajim-devel tags: @@ -48,6 +48,7 @@ add-extensions: build-options: env: PIP_PREFIX: /app + PIP_DISABLE_PIP_VERSION_CHECK: "1"
cleanup: - /include @@ -109,33 +110,33 @@ modules: - name: python3-idna buildsystem: simple build-commands: - - pip3 install idna-3.3-py3-none-any.whl + - pip3 install idna-3.4-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/py3/i/idna/idna-3.3-py3-none-any.whl - sha256: 84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff + url: https://files.pythonhosted.org/packages/py3/i/idna/idna-3.4-py3-none-any.whl + sha256: 90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2
- name: python3-cryptography buildsystem: simple only-arches: - aarch64 build-commands: - - pip3 install cryptography-37.0.4-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl + - pip3 install cryptography-38.0.1-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl sources: - type: file - url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-37.... - sha256: 80f49023dd13ba35f7c34072fa17f604d2f19bf0989f292cedf7ab5770b87a0b + url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-38.... + sha256: 194044c6b89a2f9f169df475cc167f6157eb9151cc69af8a2a163481d45cc407
- name: python3-cryptography buildsystem: simple only-arches: - x86_64 build-commands: - - pip3 install cryptography-37.0.4-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + - pip3 install cryptography-38.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl sources: - type: file - url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-37.... - sha256: f2dcb0b3b63afb6df7fd94ec6fbddac81b5492513f7b0436210d390c14d46ee8 + url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-38.... + sha256: ca9f6784ea96b55ff41708b92c3f6aeaebde4c560308e5fbbd3173fbc466e94e
- name: python3-pyopenssl buildsystem: simple @@ -152,8 +153,8 @@ modules: PYTHON_VERSION: '3' sources: - type: archive - url: https://files.pythonhosted.org/packages/source/d/dbus-python/dbus-python-1.2... - sha256: 92bdd1e68b45596c833307a5ff4b217ee6929a1502f5341bae28fd120acf7260 + url: https://files.pythonhosted.org/packages/source/d/dbus-python/dbus-python-1.3... + sha256: ad67819308618b5069537be237f8e68ca1c7fcc95ee4a121fe6845b1418248f8
- name: python3-jeepney buildsystem: simple @@ -182,28 +183,40 @@ modules: url: https://files.pythonhosted.org/packages/py3/z/zipp/zipp-3.8.1-py3-none-any.w... sha256: 47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009
+ # jaraco.classes dependency + - name: python3-more-itertools + buildsystem: simple + build-commands: + - pip3 install more_itertools-8.14.0-py3-none-any.whl + cleanup: + - /bin + sources: + - type: file + url: https://files.pythonhosted.org/packages/py3/m/more_itertools/more_itertools-... + sha256: 1bc4f91ee5b1b31ac7ceacc17c09befe6a40a503907baf9c839c229b5095cfd2 + # keyring dependency - - name: python3-importlib-metadata + - name: python3-jaraco.classes buildsystem: simple build-commands: - - pip3 install importlib_metadata-4.12.0-py3-none-any.whl + - pip3 install jaraco.classes-3.2.2-py3-none-any.whl cleanup: - /bin sources: - type: file - url: https://files.pythonhosted.org/packages/py3/i/importlib_metadata/importlib_m... - sha256: 7401a975809ea1fdc658c3aa4f78cc2195a0e019c5cbc4c06122884e9ae80c23 + url: https://files.pythonhosted.org/packages/py3/j/jaraco.classes/jaraco.classes-... + sha256: e6ef6fd3fcf4579a7a019d87d1e56a883f4e4c35cfe925f86731abc58804e647
- name: python3-keyring buildsystem: simple build-commands: - - pip3 install keyring-23.8.2-py3-none-any.whl + - pip3 install keyring-23.9.3-py3-none-any.whl cleanup: - /bin sources: - type: file - url: https://files.pythonhosted.org/packages/py3/k/keyring/keyring-23.8.2-py3-non... - sha256: 10d2a8639663fe2090705a00b8c47c687cacdf97598ea9c11456679fa974473a + url: https://files.pythonhosted.org/packages/py3/k/keyring/keyring-23.9.3-py3-non... + sha256: 69732a15cb1433bdfbc3b980a8a36a04878a6cfd7cb99f497b573f31618001c0
- name: python3-css-parser buildsystem: simple @@ -223,25 +236,6 @@ modules: url: https://files.pythonhosted.org/packages/py3/p/precis_i18n/precis_i18n-1.0.4-... sha256: 8b4f6100c2f5e44db61081d53c9c07ff92e50d0a7b36eedd2f4fb7d40c48576d
- # gssapi dependency - - name: python3-decorator - buildsystem: simple - build-commands: - - pip3 install decorator-5.1.1-py3-none-any.whl - sources: - - type: file - url: https://files.pythonhosted.org/packages/py3/d/decorator/decorator-5.1.1-py3-... - sha256: b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186 - - - name: python3-gssapi - buildsystem: simple - build-commands: - - pip3 install --no-build-isolation . - sources: - - type: archive - url: https://files.pythonhosted.org/packages/source/g/gssapi/gssapi-1.8.1.tar.gz - sha256: 893aa38ae769d1febe89963aa9f59194a966736ade2263fe14e0081126d64a72 - # GSound dependency - shared-modules/libcanberra/libcanberra.json
@@ -291,20 +285,40 @@ modules: - name: python3-certifi buildsystem: simple build-commands: - - pip3 install certifi-2022.6.15-py3-none-any.whl + - pip3 install certifi-2022.9.14-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/py3/c/certifi/certifi-2022.6.15-py3-... - sha256: fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412 + url: https://files.pythonhosted.org/packages/py3/c/certifi/certifi-2022.9.14-py3-... + sha256: e232343de1ab72c2aa521b625c80f699e356830fd0e2c620b465b304b17b0516
- name: python3-sentry-sdk buildsystem: simple build-commands: - - pip3 install sentry_sdk-1.9.5-py2.py3-none-any.whl + - pip3 install sentry_sdk-1.9.8-py2.py3-none-any.whl + sources: + - type: file + url: https://files.pythonhosted.org/packages/py2.py3/s/sentry_sdk/sentry_sdk-1.9.... + sha256: 7378c08d81da78a4860da7b4900ac51fef38be841d01bc5b7cb249ac51e070c6 + + # gssapi dependency + - name: python3-decorator + buildsystem: simple + build-commands: + - pip3 install decorator-5.1.1-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/py2.py3/s/sentry_sdk/sentry_sdk-1.9.... - sha256: b4b41f90951ed83e7b4c176eef021b19ecba39da5b73aca106c97a9b7e279a90 + url: https://files.pythonhosted.org/packages/py3/d/decorator/decorator-5.1.1-py3-... + sha256: b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186 + + # nbxmpp dependency (optional) + - name: python3-gssapi + buildsystem: simple + build-commands: + - pip3 install -v --no-build-isolation . + sources: + - type: archive + url: https://files.pythonhosted.org/packages/source/g/gssapi/gssapi-1.8.1.tar.gz + sha256: 893aa38ae769d1febe89963aa9f59194a966736ade2263fe14e0081126d64a72
- name: python3-nbxmpp buildsystem: simple
===================================== flatpak/org.gajim.Gajim.yaml ===================================== @@ -1,6 +1,6 @@ app-id: org.gajim.Gajim runtime: org.gnome.Platform -runtime-version: '42' +runtime-version: '43' sdk: org.gnome.Sdk command: gajim finish-args: @@ -41,6 +41,7 @@ add-extensions: build-options: env: PIP_PREFIX: /app + PIP_DISABLE_PIP_VERSION_CHECK: "1"
cleanup: - /include @@ -102,33 +103,33 @@ modules: - name: python3-idna buildsystem: simple build-commands: - - pip3 install idna-3.3-py3-none-any.whl + - pip3 install idna-3.4-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/py3/i/idna/idna-3.3-py3-none-any.whl - sha256: 84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff + url: https://files.pythonhosted.org/packages/py3/i/idna/idna-3.4-py3-none-any.whl + sha256: 90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2
- name: python3-cryptography buildsystem: simple only-arches: - aarch64 build-commands: - - pip3 install cryptography-37.0.4-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl + - pip3 install cryptography-38.0.1-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl sources: - type: file - url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-37.... - sha256: 80f49023dd13ba35f7c34072fa17f604d2f19bf0989f292cedf7ab5770b87a0b + url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-38.... + sha256: 194044c6b89a2f9f169df475cc167f6157eb9151cc69af8a2a163481d45cc407
- name: python3-cryptography buildsystem: simple only-arches: - x86_64 build-commands: - - pip3 install cryptography-37.0.4-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + - pip3 install cryptography-38.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl sources: - type: file - url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-37.... - sha256: f2dcb0b3b63afb6df7fd94ec6fbddac81b5492513f7b0436210d390c14d46ee8 + url: https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-38.... + sha256: ca9f6784ea96b55ff41708b92c3f6aeaebde4c560308e5fbbd3173fbc466e94e
- name: python3-pyopenssl buildsystem: simple @@ -145,8 +146,8 @@ modules: PYTHON_VERSION: '3' sources: - type: archive - url: https://files.pythonhosted.org/packages/source/d/dbus-python/dbus-python-1.2... - sha256: 92bdd1e68b45596c833307a5ff4b217ee6929a1502f5341bae28fd120acf7260 + url: https://files.pythonhosted.org/packages/source/d/dbus-python/dbus-python-1.3... + sha256: ad67819308618b5069537be237f8e68ca1c7fcc95ee4a121fe6845b1418248f8
- name: python3-jeepney buildsystem: simple @@ -175,28 +176,40 @@ modules: url: https://files.pythonhosted.org/packages/py3/z/zipp/zipp-3.8.1-py3-none-any.w... sha256: 47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009
+ # jaraco.classes dependency + - name: python3-more-itertools + buildsystem: simple + build-commands: + - pip3 install more_itertools-8.14.0-py3-none-any.whl + cleanup: + - /bin + sources: + - type: file + url: https://files.pythonhosted.org/packages/py3/m/more_itertools/more_itertools-... + sha256: 1bc4f91ee5b1b31ac7ceacc17c09befe6a40a503907baf9c839c229b5095cfd2 + # keyring dependency - - name: python3-importlib-metadata + - name: python3-jaraco.classes buildsystem: simple build-commands: - - pip3 install importlib_metadata-4.12.0-py3-none-any.whl + - pip3 install jaraco.classes-3.2.2-py3-none-any.whl cleanup: - /bin sources: - type: file - url: https://files.pythonhosted.org/packages/py3/i/importlib_metadata/importlib_m... - sha256: 7401a975809ea1fdc658c3aa4f78cc2195a0e019c5cbc4c06122884e9ae80c23 + url: https://files.pythonhosted.org/packages/py3/j/jaraco.classes/jaraco.classes-... + sha256: e6ef6fd3fcf4579a7a019d87d1e56a883f4e4c35cfe925f86731abc58804e647
- name: python3-keyring buildsystem: simple build-commands: - - pip3 install keyring-23.8.2-py3-none-any.whl + - pip3 install keyring-23.9.3-py3-none-any.whl cleanup: - /bin sources: - type: file - url: https://files.pythonhosted.org/packages/py3/k/keyring/keyring-23.8.2-py3-non... - sha256: 10d2a8639663fe2090705a00b8c47c687cacdf97598ea9c11456679fa974473a + url: https://files.pythonhosted.org/packages/py3/k/keyring/keyring-23.9.3-py3-non... + sha256: 69732a15cb1433bdfbc3b980a8a36a04878a6cfd7cb99f497b573f31618001c0
- name: python3-css-parser buildsystem: simple @@ -216,25 +229,6 @@ modules: url: https://files.pythonhosted.org/packages/py3/p/precis_i18n/precis_i18n-1.0.4-... sha256: 8b4f6100c2f5e44db61081d53c9c07ff92e50d0a7b36eedd2f4fb7d40c48576d
- # gssapi dependency - - name: python3-decorator - buildsystem: simple - build-commands: - - pip3 install decorator-5.1.1-py3-none-any.whl - sources: - - type: file - url: https://files.pythonhosted.org/packages/py3/d/decorator/decorator-5.1.1-py3-... - sha256: b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186 - - - name: python3-gssapi - buildsystem: simple - build-commands: - - pip3 install --no-build-isolation . - sources: - - type: archive - url: https://files.pythonhosted.org/packages/source/g/gssapi/gssapi-1.8.1.tar.gz - sha256: 893aa38ae769d1febe89963aa9f59194a966736ade2263fe14e0081126d64a72 - # GSound dependency - shared-modules/libcanberra/libcanberra.json
@@ -284,20 +278,40 @@ modules: - name: python3-certifi buildsystem: simple build-commands: - - pip3 install certifi-2022.6.15-py3-none-any.whl + - pip3 install certifi-2022.9.14-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/py3/c/certifi/certifi-2022.6.15-py3-... - sha256: fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412 + url: https://files.pythonhosted.org/packages/py3/c/certifi/certifi-2022.9.14-py3-... + sha256: e232343de1ab72c2aa521b625c80f699e356830fd0e2c620b465b304b17b0516
- name: python3-sentry-sdk buildsystem: simple build-commands: - - pip3 install sentry_sdk-1.9.5-py2.py3-none-any.whl + - pip3 install sentry_sdk-1.9.8-py2.py3-none-any.whl + sources: + - type: file + url: https://files.pythonhosted.org/packages/py2.py3/s/sentry_sdk/sentry_sdk-1.9.... + sha256: 7378c08d81da78a4860da7b4900ac51fef38be841d01bc5b7cb249ac51e070c6 + + # gssapi dependency + - name: python3-decorator + buildsystem: simple + build-commands: + - pip3 install decorator-5.1.1-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/py2.py3/s/sentry_sdk/sentry_sdk-1.9.... - sha256: b4b41f90951ed83e7b4c176eef021b19ecba39da5b73aca106c97a9b7e279a90 + url: https://files.pythonhosted.org/packages/py3/d/decorator/decorator-5.1.1-py3-... + sha256: b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186 + + # nbxmpp dependency (optional) + - name: python3-gssapi + buildsystem: simple + build-commands: + - pip3 install -v --no-build-isolation . + sources: + - type: archive + url: https://files.pythonhosted.org/packages/source/g/gssapi/gssapi-1.8.1.tar.gz + sha256: 893aa38ae769d1febe89963aa9f59194a966736ade2263fe14e0081126d64a72
- name: python3-nbxmpp buildsystem: simple
===================================== gajim/gajim.py ===================================== @@ -66,6 +66,7 @@ def _check_required_deps() -> None: 'GtkSource': '4', 'GObject': '2.0', 'Pango': '1.0', + 'PangoCairo': '1.0', 'Soup': '2.4'}) except ValueError as error: sys.exit('Missing dependency: %s' % error)
===================================== gajim/gtk/avatar.py ===================================== @@ -26,6 +26,8 @@
from gi.repository import Gdk from gi.repository import GdkPixbuf +from gi.repository import Pango +from gi.repository import PangoCairo import cairo from nbxmpp.protocol import JID
@@ -38,8 +40,7 @@ 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 .emoji_data_gtk import get_emoji_data from .util import load_icon_surface from .util import load_pixbuf from .util import text_to_color @@ -56,6 +57,24 @@ cairo.ImageSurface]]
+def generate_avatar_letter(text: str) -> str: + if not text: + return '' + + if text[:1].isalpha(): + return text[:1].upper() + + # Max length for emoji ZJW sequences + len = 11 + emoji_data = get_emoji_data() + while len >= 1: + if text[:len] in emoji_data.values(): + return text[:len] + len -= 1 + + return text[:1].upper() + + def generate_avatar(letters: str, color: tuple[float, float, float], size: int, @@ -70,7 +89,7 @@ def generate_avatar(letters: str,
width = size height = size - font_size = size * 0.5 + font_size = size * 0.4
# Set up surface surface = cairo.ImageSurface(cairo.Format.ARGB32, width, height) @@ -81,26 +100,25 @@ def generate_avatar(letters: str, context.fill()
# Draw letters - 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) - extends = context.text_extents(letters) - x_bearing = extends.x_bearing - y_bearing = extends.y_bearing - ex_width = extends.width - ex_height = extends.height - - x_pos = width / 2 - (ex_width / 2 + x_bearing) - y_pos = height / 2 - (ex_height / 2 + y_bearing) + layout = PangoCairo.create_layout(context) + layout.set_text(generate_avatar_letter(letters)) + + description = Pango.FontDescription() + description.set_family('Sans') + description.set_size(int(font_size * Pango.SCALE)) + + layout.set_font_description(description) + + _ink_rect, logical_rect = layout.get_extents() + layout_width = logical_rect.width / Pango.SCALE + layout_height = logical_rect.height / Pango.SCALE + x_pos = (width - layout_width) / 2 + y_pos = (height - layout_height) / 2 + context.move_to(x_pos, y_pos) context.set_source_rgb(0.95, 0.95, 0.95) context.set_operator(cairo.Operator.OVER) - context.show_text(letters) + PangoCairo.show_layout(context, layout)
return context.get_target() # pyright: ignore
@@ -399,7 +417,7 @@ def get_surface(self, name = contact.name color_string = str(contact.jid)
- letter = self._generate_letter(name) + letter = generate_avatar_letter(name) surface = generate_default_avatar( letter, color_string, size, scale, style=style) if show is not None: @@ -441,7 +459,7 @@ def get_muc_surface(self,
con = app.connections[account] name = get_groupchat_name(con, jid) - letter = self._generate_letter(name) + letter = generate_avatar_letter(name) surface = generate_default_avatar(letter, str(jid), size, scale, style) self._cache[jid][(size, scale, None)] = surface return surface @@ -469,9 +487,8 @@ def get_workspace_surface(self, app.settings.set_workspace_setting(workspace_id, 'avatar_sha', '')
rgba = make_rgba(color or DEFAULT_WORKSPACE_COLOR) - letter = name[:1].upper() surface = make_workspace_avatar( - letter, rgba_to_float(rgba), size, scale) + name, rgba_to_float(rgba), size, scale) self._cache[workspace_id][(size, scale, None)] = surface return surface
@@ -571,10 +588,3 @@ def _get_avatar_from_storage(self, if surface is None: return None return clip(surface, style) - - @staticmethod - def _generate_letter(name: str) -> str: - for letter in name: - if letter.isalpha(): - return letter.capitalize() - return name[0].capitalize()
===================================== gajim/gtk/emoji_data.py ===================================== @@ -17,7 +17,6 @@ from typing import Optional
import re -import sys import weakref from enum import IntEnum from collections import OrderedDict @@ -47,7 +46,6 @@ def is_emoji(codepoints: str) -> bool: return True return False
- def get_emoji_pixbuf(codepoints: str) -> Optional[GdkPixbuf.Pixbuf]: ascii_codepoint = emoji_ascii_data.get(codepoints, None) if ascii_codepoint is not None: @@ -62,12 +60,6 @@ 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:
===================================== gajim/gtk/emoji_data.pyi ===================================== @@ -22,7 +22,6 @@ class Emoji(IntEnum): ...
def is_emoji(codepoints: str) -> bool: ... -def get_emoji_font() -> str: ... def get_emoji_pixbuf(codepoints: str) -> GdkPixbuf.Pixbuf: ...
class EmojiData(OrderedDict):
===================================== gajim/gtk/emoji_data_gtk.py ===================================== @@ -26,6 +26,14 @@
log = logging.getLogger('gajim.gui.emoji_data_gtk')
+SKIN_TONE_MODIFIERS = { + 127995: 'light skin tone', + 127996: 'medium-light skin tone', + 127997: 'medium skin tone', + 127998: 'medium-dark skin tone', + 127999: 'dark skin tone' +} +
def get_emoji_data() -> dict[str, str]: return emoji_data @@ -57,18 +65,51 @@ def _pass(_user_data: Any) -> None: _pass)
emoji_data_dict: dict[str, str] = {} - index = 0 - for _item in variant: - emoji = variant.get_child_value(index) - points = emoji.get_child_value(0) - codepoint = points.get_child_value(0).get_uint32() - shortcode = emoji.get_child_value(1).get_string() - emoji_data_dict[shortcode] = chr(codepoint) - index += 1 + for c_sequence, shortcode, _ in variant: + # Example item: + # ([128105, 0, 8205, 10084, 65039, 8205, 128104, 0], + # 'couple with heart: woman, man', + # 'couple'), + + def generate_unicode_sequence(c_sequence: list[int]) -> str: + u_sequence = '' + for codepoint in c_sequence: + u_sequence += chr(codepoint) + return u_sequence + + if 0 not in c_sequence: + # No skin tone modifiers + u_sequence = generate_unicode_sequence(c_sequence) + emoji_data_dict[shortcode] = u_sequence + continue + + # Filter out 0 in order to generate basic (yellow) variation + c_basic_sequence = [c for c in c_sequence if c != 0] + u_sequence = generate_unicode_sequence(c_basic_sequence) + emoji_data_dict[shortcode] = u_sequence + + # Add variations with skin tone modifiers + def replace_modifier(c_sequence: list[int], + modifier: int + ) -> list[int]: + + c_mod_sequence: list[int] = [] + for codepoint in c_sequence: + if codepoint == 0: + codepoint = modifier + c_mod_sequence.append(codepoint) + return c_mod_sequence + + for modifier, mod_shortcode in SKIN_TONE_MODIFIERS.items(): + new_shortcode = f'{shortcode}, {mod_shortcode}' + c_mod_sequence = replace_modifier(c_sequence, modifier) + u_mod_sequence = generate_unicode_sequence(c_mod_sequence) + emoji_data_dict[new_shortcode] = u_mod_sequence
# Add commonly used shortcodes emoji_data_dict['+1'] = '\U0001F44D' emoji_data_dict['-1'] = '\U0001F44E' + return emoji_data_dict
except GLib.Error:
===================================== gajim/gtk/workspace_dialog.py ===================================== @@ -131,7 +131,7 @@ def _update_avatar(self) -> None: scale) else: surface = make_workspace_avatar( - name[:1].upper(), + name, rgba_to_float(rgba), AvatarSize.WORKSPACE_EDIT, scale)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/1fe1d7047504157b4f56ebeccaf0ffcf...