Implement support for emoji skin tone modifiers

Fixes #787
This commit is contained in:
Kovid Goyal
2018-08-04 10:06:25 +05:30
parent 28447d3389
commit 000c1cf306
8 changed files with 38 additions and 14 deletions

View File

@@ -304,7 +304,10 @@ width(Line *self, PyObject *val) {
void
line_add_combining_char(Line *self, uint32_t ch, unsigned int x) {
CPUCell *cell = self->cpu_cells + x;
if (!cell->ch) return; // dont allow adding combining chars to a null cell
if (!cell->ch) {
if (x > 0 && (self->gpu_cells[x-1].attrs & WIDTH_MASK) == 2 && self->cpu_cells[x-1].ch) cell = self->cpu_cells + x - 1;
else return; // dont allow adding combining chars to a null cell
}
for (unsigned i = 0; i < arraysz(cell->cc_idx); i++) {
if (!cell->cc_idx[i]) { cell->cc_idx[i] = mark_for_codepoint(ch); return; }
}