Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
73d269db
by wurstsalat at 2022-05-26T14:33:08+02:00
2 changed files:
Changes:
| ... | ... | @@ -38,6 +38,8 @@ |
| 38 | 38 | from gajim.common.const import StyleAttr
|
| 39 | 39 | |
| 40 | 40 | from .const import DEFAULT_WORKSPACE_COLOR
|
| 41 | +from .emoji_data import is_emoji
|
|
| 42 | +from .emoji_data import get_emoji_font
|
|
| 41 | 43 | from .util import load_icon_surface
|
| 42 | 44 | from .util import load_pixbuf
|
| 43 | 45 | from .util import text_to_color
|
| ... | ... | @@ -79,7 +81,11 @@ def generate_avatar(letters: str, |
| 79 | 81 | context.fill()
|
| 80 | 82 | |
| 81 | 83 | # Draw letters
|
| 82 | - context.select_font_face('sans-serif',
|
|
| 84 | + if is_emoji(letters):
|
|
| 85 | + font_face = get_emoji_font()
|
|
| 86 | + else:
|
|
| 87 | + font_face = 'sans-serif'
|
|
| 88 | + context.select_font_face(font_face,
|
|
| 83 | 89 | cairo.FontSlant.NORMAL,
|
| 84 | 90 | cairo.FontWeight.NORMAL)
|
| 85 | 91 | context.set_font_size(font_size)
|
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | from typing import Optional
|
| 18 | 18 | |
| 19 | 19 | import re
|
| 20 | +import sys
|
|
| 20 | 21 | import weakref
|
| 21 | 22 | from enum import IntEnum
|
| 22 | 23 | from collections import OrderedDict
|
| ... | ... | @@ -61,6 +62,12 @@ def get_emoji_pixbuf(codepoints: str) -> Optional[GdkPixbuf.Pixbuf]: |
| 61 | 62 | return pixbuf
|
| 62 | 63 | |
| 63 | 64 | |
| 65 | +def get_emoji_font() -> str:
|
|
| 66 | + if sys.platform == 'win32':
|
|
| 67 | + return 'Segoe UI Emoji'
|
|
| 68 | + return 'Noto Color Emoji'
|
|
| 69 | + |
|
| 70 | + |
|
| 64 | 71 | class EmojiData(OrderedDict):
|
| 65 | 72 | def __getitem__(self, key):
|
| 66 | 73 | try:
|