Handle multiple spaces after PUA glyphs
This commit is contained in:
parent
e498cedf56
commit
efc0b830cf
@ -901,12 +901,12 @@ shape_run(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells
|
|||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
merge_groups_for_pua_space_ligature() {
|
merge_groups_for_pua_space_ligature() {
|
||||||
if (G(group_idx) == 1) {
|
while (G(group_idx) > 0) {
|
||||||
Group *g = G(groups), *g1 = G(groups) + 1;
|
Group *g = G(groups), *g1 = G(groups) + 1;
|
||||||
g->num_cells += g1->num_cells;
|
g->num_cells += g1->num_cells;
|
||||||
g->num_glyphs += g1->num_glyphs;
|
g->num_glyphs += g1->num_glyphs;
|
||||||
g->num_glyphs = MIN(g->num_glyphs, MAX_NUM_EXTRA_GLYPHS + 1);
|
g->num_glyphs = MIN(g->num_glyphs, MAX_NUM_EXTRA_GLYPHS + 1);
|
||||||
G(group_idx) = 0;
|
G(group_idx)--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,21 +1006,33 @@ render_line(FONTS_DATA_HANDLE fg_, Line *line) {
|
|||||||
CPUCell *cpu_cell = line->cpu_cells + i;
|
CPUCell *cpu_cell = line->cpu_cells + i;
|
||||||
GPUCell *gpu_cell = line->gpu_cells + i;
|
GPUCell *gpu_cell = line->gpu_cells + i;
|
||||||
ssize_t cell_font_idx = font_for_cell(fg, cpu_cell, gpu_cell);
|
ssize_t cell_font_idx = font_for_cell(fg, cpu_cell, gpu_cell);
|
||||||
if (is_private_use(cpu_cell->ch) && i + 1 < line->xnum && (line->cpu_cells[i+1].ch == ' ' || line->cpu_cells[i+1].ch == 0) && cell_font_idx != BOX_FONT && cell_font_idx != MISSING_FONT) {
|
if (is_private_use(cpu_cell->ch)
|
||||||
// We have a private use char followed by a space char, render it as a two cell ligature.
|
&& cell_font_idx != BOX_FONT
|
||||||
GPUCell *space_cell = line->gpu_cells + i+1;
|
&& cell_font_idx != MISSING_FONT) {
|
||||||
// Ensure the space cell uses the foreground colors from the PUA cell
|
int j = 0;
|
||||||
// This is needed because there are stupid applications like
|
while ((line->cpu_cells[i+1+j].ch == ' ' || line->cpu_cells[i+1+j].ch == 0)
|
||||||
// powerline that use PUA+space with different foreground colors
|
&& j < MAX_NUM_EXTRA_GLYPHS
|
||||||
// for the space and the PUA. See for example: https://github.com/kovidgoyal/kitty/issues/467
|
&& i + 1 + j < line->xnum) {
|
||||||
space_cell->fg = gpu_cell->fg; space_cell->decoration_fg = gpu_cell->decoration_fg;
|
j++;
|
||||||
RENDER;
|
// We have a private use char followed by space(s), render it as a multi-cell ligature.
|
||||||
render_run(fg, line->cpu_cells + i, line->gpu_cells + i, 2, cell_font_idx, true);
|
GPUCell *space_cell = line->gpu_cells + i+j;
|
||||||
run_font_idx = NO_FONT;
|
// Ensure the space cell uses the foreground/background colors from the PUA cell.
|
||||||
first_cell_in_run = i + 2;
|
// This is needed because there are stupid applications like
|
||||||
prev_width = line->gpu_cells[i+1].attrs & WIDTH_MASK;
|
// powerline that use PUA+space with different foreground colors
|
||||||
i++;
|
// for the space and the PUA. See for example: https://github.com/kovidgoyal/kitty/issues/467
|
||||||
continue;
|
space_cell->fg = gpu_cell->fg;
|
||||||
|
space_cell->bg = gpu_cell->bg;
|
||||||
|
space_cell->decoration_fg = gpu_cell->decoration_fg;
|
||||||
|
}
|
||||||
|
if (j) {
|
||||||
|
RENDER;
|
||||||
|
render_run(fg, line->cpu_cells + i, line->gpu_cells + i, j + 1, cell_font_idx, true);
|
||||||
|
run_font_idx = NO_FONT;
|
||||||
|
first_cell_in_run = i + 1 + j;
|
||||||
|
prev_width = gpu_cell->attrs & WIDTH_MASK;
|
||||||
|
i += j;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prev_width = gpu_cell->attrs & WIDTH_MASK;
|
prev_width = gpu_cell->attrs & WIDTH_MASK;
|
||||||
if (run_font_idx == NO_FONT) run_font_idx = cell_font_idx;
|
if (run_font_idx == NO_FONT) run_font_idx = cell_font_idx;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user