Merge branch 'pua-double-width'

This commit is contained in:
Daniel Eklöf 2021-06-01 17:51:25 +02:00
commit f74c5fa9f0
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 35 additions and 8 deletions

View file

@ -57,6 +57,9 @@
(https://codeberg.org/dnkl/foot/issues/555). (https://codeberg.org/dnkl/foot/issues/555).
* `ENVIRONMENT` section in **foot**(1) and **footclient**(1) man pages * `ENVIRONMENT` section in **foot**(1) and **footclient**(1) man pages
(https://codeberg.org/dnkl/foot/issues/556). (https://codeberg.org/dnkl/foot/issues/556).
* `tweak.pua-double-width` option to `foot.ini`, letting you force
_Private Usage Area_ codepoints to be treated as double-width
characters.
### Changed ### Changed

View file

@ -2005,6 +2005,12 @@ parse_section_tweak(
LOG_WARN("tweak: disabled overflowing double-width glyphs"); LOG_WARN("tweak: disabled overflowing double-width glyphs");
} }
else if (strcmp(key, "pua-double-width") == 0) {
conf->tweak.pua_double_width = str_to_bool(value);
if (conf->tweak.pua_double_width)
LOG_WARN("tweak: PUA double width glyphs enabled");
}
else if (strcmp(key, "damage-whole-window") == 0) { else if (strcmp(key, "damage-whole-window") == 0) {
conf->tweak.damage_whole_window = str_to_bool(value); conf->tweak.damage_whole_window = str_to_bool(value);
if (conf->tweak.damage_whole_window) if (conf->tweak.damage_whole_window)
@ -2573,6 +2579,7 @@ config_load(struct config *conf, const char *conf_path,
.damage_whole_window = false, .damage_whole_window = false,
.box_drawing_base_thickness = 0.04, .box_drawing_base_thickness = 0.04,
.box_drawing_solid_shades = true, .box_drawing_solid_shades = true,
.pua_double_width = false,
}, },
.notifications = tll_init(), .notifications = tll_init(),

View file

@ -237,6 +237,7 @@ struct config {
off_t max_shm_pool_size; off_t max_shm_pool_size;
float box_drawing_base_thickness; float box_drawing_base_thickness;
bool box_drawing_solid_shades; bool box_drawing_solid_shades;
bool pua_double_width;
} tweak; } tweak;
user_notifications_t notifications; user_notifications_t notifications;

View file

@ -826,7 +826,7 @@ any of these options.
Default: _lanczos3_. Default: _lanczos3_.
*allow-overflowing-double-width-glyphs* *allow-overflowing-double-width-glyphs*
Boolean. when enabled, double width glyphs with a character width Boolean. When enabled, double width glyphs with a character width
of 1 are allowed to overflow into the neighbouring cell. of 1 are allowed to overflow into the neighbouring cell.
One use case for this is fonts "icon" characters in the Unicode One use case for this is fonts "icon" characters in the Unicode
@ -839,8 +839,20 @@ any of these options.
Note: this feature uses _heuristics_ to determine *which* glyphs Note: this feature uses _heuristics_ to determine *which* glyphs
should be allowed to overflow. should be allowed to overflow.
See also: *pua-double-width*
Default: _yes_. Default: _yes_.
*pua-double-width*
Boolean. When enabled, Unicode code points from the private usage
area (PUA) are always considered to be double width, regardless of
the actual glyph width.
Ignored if *allow-overflowing-double-width-glyphs* has been
disabled.
Default: _no_.
*render-timer* *render-timer*
Enables a frame rendering timer, that prints the time it takes to Enables a frame rendering timer, that prints the time it takes to
render each frame, in microseconds, either on-screen, to stderr, render each frame, in microseconds, either on-screen, to stderr,

View file

@ -499,9 +499,9 @@ render_cell(struct terminal *term, pixman_image_t *pix,
const struct fcft_glyph *glyph = NULL; const struct fcft_glyph *glyph = NULL;
const struct composed *composed = NULL; const struct composed *composed = NULL;
if (cell->wc != 0) { wchar_t base = cell->wc;
wchar_t base = cell->wc;
if (base != 0) {
if (base >= CELL_COMB_CHARS_LO && if (base >= CELL_COMB_CHARS_LO &&
base < (CELL_COMB_CHARS_LO + term->composed_count)) base < (CELL_COMB_CHARS_LO + term->composed_count))
{ {
@ -576,11 +576,15 @@ render_cell(struct terminal *term, pixman_image_t *pix,
* - *this* cells is followed by an empty cell, or a space * - *this* cells is followed by an empty cell, or a space
*/ */
if (term->conf->tweak.allow_overflowing_double_width_glyphs && if (term->conf->tweak.allow_overflowing_double_width_glyphs &&
glyph != NULL && ((glyph != NULL &&
glyph->cols == 1 && glyph->cols == 1 &&
glyph->width >= term->cell_width * 15 / 10 && glyph->width >= term->cell_width * 15 / 10 &&
glyph->width < 3 * term->cell_width && glyph->width < 3 * term->cell_width &&
col < term->cols - 1 && col < term->cols - 1) ||
(term->conf->tweak.pua_double_width &&
((base >= 0x00e000 && base <= 0x00f8ff) ||
(base >= 0x0f0000 && base <= 0x0ffffd) ||
(base >= 0x100000 && base <= 0x10fffd)))) &&
(row->cells[col + 1].wc == 0 || row->cells[col + 1].wc == L' ')) (row->cells[col + 1].wc == 0 || row->cells[col + 1].wc == L' '))
{ {
cell_cols = 2; cell_cols = 2;