diff --git a/docs/changelog.rst b/docs/changelog.rst index 00e012bee..fbfad945e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix a regression in 0.20.0 that sent incorrect bytes for the :kbd:`F1-F4` keys in rmkx mode (:iss:`3586`) +- macOS: When the Apple Color Emoji font lacks an emoji glyph search for it in other + installed fonts (:iss:`3591`) + 0.20.3 [2021-05-06] ---------------------- diff --git a/kitty/core_text.m b/kitty/core_text.m index b3065f621..72f99e1d9 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -250,15 +250,22 @@ PyObject* create_fallback_face(PyObject *base_face, CPUCell* cell, bool UNUSED bold, bool UNUSED italic, bool emoji_presentation, FONTS_DATA_HANDLE fg UNUSED) { CTFace *self = (CTFace*)base_face; CTFontRef new_font; - if (emoji_presentation) new_font = CTFontCreateWithName((CFStringRef)@"AppleColorEmoji", self->scaled_point_sz, NULL); - else { - char text[64] = {0}; - cell_as_utf8_for_fallback(cell, text); - CFStringRef str = CFStringCreateWithCString(NULL, text, kCFStringEncodingUTF8); - if (str == NULL) return PyErr_NoMemory(); - new_font = find_substitute_face(str, self->ct_font, cell); +#define search_for_fallback() \ + char text[64] = {0}; \ + cell_as_utf8_for_fallback(cell, text); \ + CFStringRef str = CFStringCreateWithCString(NULL, text, kCFStringEncodingUTF8); \ + if (str == NULL) return PyErr_NoMemory(); \ + new_font = find_substitute_face(str, self->ct_font, cell); \ CFRelease(str); + + if (emoji_presentation) { + new_font = CTFontCreateWithName((CFStringRef)@"AppleColorEmoji", self->scaled_point_sz, NULL); + if (!new_font || !glyph_id_for_codepoint_ctfont(new_font, cell->ch)) { + if (new_font) CFRelease(new_font); + search_for_fallback(); + } } + else { search_for_fallback(); } if (new_font == NULL) return NULL; return (PyObject*)ct_face(new_font); }