Exclude variation selectors when finding fallback font
This commit is contained in:
parent
529337e00a
commit
1369a36178
@ -192,7 +192,7 @@ create_fallback_face(PyObject *base_face, CPUCell* cell, bool UNUSED bold, bool
|
|||||||
if (emoji_presentation) new_font = CTFontCreateWithName((CFStringRef)@"AppleColorEmoji", self->scaled_point_sz, NULL);
|
if (emoji_presentation) new_font = CTFontCreateWithName((CFStringRef)@"AppleColorEmoji", self->scaled_point_sz, NULL);
|
||||||
else {
|
else {
|
||||||
char text[256] = {0};
|
char text[256] = {0};
|
||||||
cell_as_utf8(cell, true, text, ' ');
|
cell_as_utf8_for_fallback(cell, text);
|
||||||
CFStringRef str = CFStringCreateWithCString(NULL, text, kCFStringEncodingUTF8);
|
CFStringRef str = CFStringCreateWithCString(NULL, text, kCFStringEncodingUTF8);
|
||||||
if (str == NULL) return PyErr_NoMemory();
|
if (str == NULL) return PyErr_NoMemory();
|
||||||
new_font = find_substitute_face(str, self->ct_font);
|
new_font = find_substitute_face(str, self->ct_font);
|
||||||
|
|||||||
@ -210,7 +210,7 @@ create_fallback_face(PyObject UNUSED *base_face, CPUCell* cell, bool bold, bool
|
|||||||
if (!emoji_presentation && bold) { AP(FcPatternAddInteger, FC_WEIGHT, FC_WEIGHT_BOLD, "weight"); }
|
if (!emoji_presentation && bold) { AP(FcPatternAddInteger, FC_WEIGHT, FC_WEIGHT_BOLD, "weight"); }
|
||||||
if (!emoji_presentation && italic) { AP(FcPatternAddInteger, FC_SLANT, FC_SLANT_ITALIC, "slant"); }
|
if (!emoji_presentation && italic) { AP(FcPatternAddInteger, FC_SLANT, FC_SLANT_ITALIC, "slant"); }
|
||||||
if (emoji_presentation) { AP(FcPatternAddBool, FC_COLOR, true, "color"); }
|
if (emoji_presentation) { AP(FcPatternAddBool, FC_COLOR, true, "color"); }
|
||||||
size_t num = cell_as_unicode(cell, true, char_buf, ' ');
|
size_t num = cell_as_unicode_for_fallback(cell, char_buf);
|
||||||
add_charset(pat, num);
|
add_charset(pat, num);
|
||||||
PyObject *d = _fc_match(pat);
|
PyObject *d = _fc_match(pat);
|
||||||
if (d) { ans = face_from_descriptor(d, fg); Py_CLEAR(d); }
|
if (d) { ans = face_from_descriptor(d, fg); Py_CLEAR(d); }
|
||||||
|
|||||||
@ -545,6 +545,7 @@ START_ALLOW_CASE_RANGE
|
|||||||
ans = fg->bi_font_idx; break;
|
ans = fg->bi_font_idx; break;
|
||||||
}
|
}
|
||||||
if (ans < 0) ans = fg->medium_font_idx;
|
if (ans < 0) ans = fg->medium_font_idx;
|
||||||
|
printf("has_emoji_presentation: %d has_cell_text: %d\n", has_emoji_presentation(cpu_cell, gpu_cell), has_cell_text(fg->fonts + ans, cpu_cell));
|
||||||
if (!has_emoji_presentation(cpu_cell, gpu_cell) && has_cell_text(fg->fonts + ans, cpu_cell)) return ans;
|
if (!has_emoji_presentation(cpu_cell, gpu_cell) && has_cell_text(fg->fonts + ans, cpu_cell)) return ans;
|
||||||
return fallback_font(fg, cpu_cell, gpu_cell);
|
return fallback_font(fg, cpu_cell, gpu_cell);
|
||||||
}
|
}
|
||||||
|
|||||||
23
kitty/line.c
23
kitty/line.c
@ -183,6 +183,16 @@ cell_as_unicode(CPUCell *cell, bool include_cc, Py_UCS4 *buf, char_type zero_cha
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
cell_as_unicode_for_fallback(CPUCell *cell, Py_UCS4 *buf) {
|
||||||
|
size_t n = 1;
|
||||||
|
buf[0] = cell->ch ? cell->ch : ' ';
|
||||||
|
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||||
|
if (cell->cc_idx[i] != VS15 && cell->cc_idx[i] != VS16) buf[n++] = codepoint_for_mark(cell->cc_idx[i]);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type zero_char) {
|
cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type zero_char) {
|
||||||
size_t n = encode_utf8(cell->ch ? cell->ch : zero_char, buf);
|
size_t n = encode_utf8(cell->ch ? cell->ch : zero_char, buf);
|
||||||
@ -193,6 +203,19 @@ cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type zero_char) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
cell_as_utf8_for_fallback(CPUCell *cell, char *buf) {
|
||||||
|
size_t n = encode_utf8(cell->ch ? cell->ch : ' ', buf);
|
||||||
|
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||||
|
if (cell->cc_idx[i] != VS15 && cell->cc_idx[i] != VS16) {
|
||||||
|
n += encode_utf8(codepoint_for_mark(cell->cc_idx[i]), buf + n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf[n] = 0;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PyObject*
|
PyObject*
|
||||||
unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc, char leading_char) {
|
unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc, char leading_char) {
|
||||||
|
|||||||
@ -64,7 +64,9 @@ index_type line_url_end_at(Line *self, index_type x, bool, char_type);
|
|||||||
index_type line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool*);
|
index_type line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool*);
|
||||||
unsigned int line_length(Line *self);
|
unsigned int line_length(Line *self);
|
||||||
size_t cell_as_unicode(CPUCell *cell, bool include_cc, Py_UCS4 *buf, char_type);
|
size_t cell_as_unicode(CPUCell *cell, bool include_cc, Py_UCS4 *buf, char_type);
|
||||||
|
size_t cell_as_unicode_for_fallback(CPUCell *cell, Py_UCS4 *buf);
|
||||||
size_t cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type);
|
size_t cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type);
|
||||||
|
size_t cell_as_utf8_for_fallback(CPUCell *cell, char *buf);
|
||||||
PyObject* unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc, char leading_char);
|
PyObject* unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc, char leading_char);
|
||||||
PyObject* line_as_unicode(Line *);
|
PyObject* line_as_unicode(Line *);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user