Add missing association between char & glyph id

This commit is contained in:
Benoit de Chezelles 2019-10-18 06:08:20 +02:00
parent d1cf771c14
commit 43a98a1df1
2 changed files with 31 additions and 10 deletions

View File

@ -543,6 +543,14 @@ in_symbol_maps(FontGroup *fg, char_type ch) {
}
// Decides which 'font' to use for a given cell.
//
// Possible results:
// - NO_FONT
// - MISSING_FONT
// - BLANK_FONT
// - BOX_FONT
// - an index in the fonts list
static inline ssize_t
font_for_cell(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell, bool *is_fallback_font, bool *is_emoji_presentation) {
*is_fallback_font = false;
@ -592,22 +600,31 @@ set_sprite(GPUCell *cell, sprite_index x, sprite_index y, sprite_index z) {
cell->sprite_x = x; cell->sprite_y = y; cell->sprite_z = z;
}
// Gives a unique (arbitrary) id to a box glyph
static inline glyph_index
box_glyph_id(char_type ch) {
START_ALLOW_CASE_RANGE
switch(ch) {
case 0x2500 ... 0x259f:
return ch - 0x2500;
case 0xe0b0:
return 0xfa;
case 0xe0b2:
return 0xfb;
case 0xe0b4:
return 0xfc;
case 0xe0b6:
return 0xfd;
case 0xe0b0: // 
return 0x0fa;
case 0xe0b2: // 
return 0x0fb;
case 0xe0b4: // 
return 0x0fc;
case 0xe0b6: // 
return 0x0fd;
case 0xe0b8: // 
return 0x0fe;
case 0xe0ba: // 
return 0x0ff;
case 0xe0bc: // 
return 0x100;
case 0xe0be: // 
return 0x101;
default:
return 0xff;
return 0xfff;
}
END_ALLOW_CASE_RANGE
}

View File

@ -2,6 +2,11 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
#
# NOTE: to add a new glyph, add an entry to the `box_chars` dict, then update
# the functions `font_for_cell` and `box_glyph_id` in `kitty/fonts.c`.
#
import math
from functools import partial as p
from itertools import repeat
@ -173,7 +178,6 @@ def triangle(buf, width, height, left=True):
def corner_triangle(buf, width, height, corner):
print(f"corner_triangle: corner is '{corner}'")
if corner == 'top-right' or corner == 'bottom-left':
diagonal_y = line_equation(0, 0, width - 1, height - 1)
if corner == 'top-right':