aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-09-06 06:28:20 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-09-06 06:28:20 +0000
commitdd19173989b3f0d1558be674bac4329fdc79dda6 (patch)
tree9a0b2c96f9864a242f9ae70095e7d80c5017755c /render.c
parentMerge branch 'handle-xdg-output-manager-coming-after-output-objects' into master (diff)
parentdoc: foot.ini: remove empty lines after option name (diff)
Merge branch 'improve-handling-of-private-usage-area-characters' into master
Closes #116
Diffstat (limited to 'render.c')
-rw-r--r--render.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/render.c b/render.c
index 08caabc7..ea21b808 100644
--- a/render.c
+++ b/render.c
@@ -433,6 +433,31 @@ render_cell(struct terminal *term, pixman_image_t *pix,
const int cols_left = term->cols - col;
int cell_cols = glyph != NULL ? max(1, min(glyph->cols, cols_left)) : 1;
+ /*
+ * Hack!
+ *
+ * Deal with double-width glyphs for which wcwidth() returns
+ * 1. Typically Unicode private usage area characters,
+ * e.g. powerline, or nerd hack fonts.
+ *
+ * Users can enable a tweak option that lets this glyphs
+ * overflow/bleed into the neighbouring cell.
+ *
+ * We only apply this workaround if:
+ * - the user has explicitly enabled this feature
+ * - the *character* width is 1
+ * - the *glyph* width is at least 1.5 cells
+ * - the *glyph* width is less than 3 cells
+ */
+ if (term->conf->tweak.allow_overflowing_double_width_glyphs &&
+ glyph != NULL &&
+ glyph->cols == 1 &&
+ glyph->width >= term->cell_width * 15 / 10 &&
+ glyph->width < 3 * term->cell_width)
+ {
+ cell_cols = min(2, cols_left);
+ }
+
pixman_region32_t clip;
pixman_region32_init_rect(
&clip, x, y,