aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-04-10 09:11:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-04-10 09:11:47 +0000
commitf78ba6653f591fc4c72ead45b3f6e66063fdab0b (patch)
treebe563000f53c86cfd61db1595a04715fce5b5fbe
parentMerge branch 'underline-cursor-below-text-underline' (diff)
parentdoc: foot.ini: codespell: antaliasing -> antialiasing (diff)
Merge branch 'optionally-render-box-drawing-characters-using-font-glyphs'
Closes #430
-rw-r--r--CHANGELOG.md2
-rw-r--r--config.c4
-rw-r--r--config.h2
-rw-r--r--doc/foot.ini.5.scd18
-rw-r--r--foot.ini1
-rw-r--r--render.c4
6 files changed, 30 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 496920dd..a97e4e53 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,8 @@
(https://codeberg.org/dnkl/foot/issues/436).
* OSC 17/117/19/119 - change/reset selection background/foreground
color.
+* `box-drawings-uses-font-glyphs=yes|no` option to `foot.ini`
+ (https://codeberg.org/dnkl/foot/issues/430).
### Changed
diff --git a/config.c b/config.c
index 8809163c..653c3f8a 100644
--- a/config.c
+++ b/config.c
@@ -770,6 +770,9 @@ parse_section_main(const char *key, const char *value, struct config *conf,
}
}
+ else if (strcmp(key, "box-drawings-uses-font-glyphs") == 0)
+ conf->box_drawings_uses_font_glyphs = str_to_bool(value);
+
else {
LOG_AND_NOTIFY_ERR("%s:%u: [default]: %s: invalid key", path, lineno, key);
return false;
@@ -2198,6 +2201,7 @@ config_load(struct config *conf, const char *conf_path,
.letter_spacing = { .pt = 0, .px = 0, },
.horizontal_letter_offset = {.pt = 0, .px = 0, },
.vertical_letter_offset = {.pt = 0, .px = 0, },
+ .box_drawings_uses_font_glyphs = false,
.dpi_aware = DPI_AWARE_AUTO, /* DPI-aware when scaling-factor == 1 */
.scrollback = {
.lines = 1000,
diff --git a/config.h b/config.h
index 696c57b6..d64c5e98 100644
--- a/config.h
+++ b/config.h
@@ -99,6 +99,8 @@ struct config {
struct pt_or_px horizontal_letter_offset;
struct pt_or_px vertical_letter_offset;
+ bool box_drawings_uses_font_glyphs;
+
struct {
int lines;
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index dcf644ef..90dfde13 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -96,6 +96,24 @@ in this order:
Default: _0_.
+*box-drawings-uses-font-glyphs*
+ Boolean. When disabled, foot generates box/line drawing characters
+ itself. The are several advantages to doing this instead of using
+ font glyphs:
+
+ - No antialiasing effects where e.g. line endpoints appear dimmer.
+ - Line- and box characters are guaranteed to span the entire cell,
+ resulting in a gap-less appearance.
+ - No alignment issues, i.e. lines are centered when they should be.
+ - Many fonts lack some, or all, of the line- and box drawing
+ characters, causing fallback fonts to be used, which results
+ in out-of-place (for example, badly sized) looking glyphs.
+
+ When enabled, box/line drawing characters are rendered using font
+ glyphs. This may result in a more uniform look, in some use cases.
+
+ Default: _no_.
+
*dpi-aware*
*auto*, *yes*, or *no*. When set to *yes*, fonts are sized using
the monitor's DPI, making a font of a given size have the same
diff --git a/foot.ini b/foot.ini
index 0c2d3f5b..a194a145 100644
--- a/foot.ini
+++ b/foot.ini
@@ -12,6 +12,7 @@
# letter-spacing=0
# horizontal-letter-offset=0
# vertical-letter-offset=0
+# box-drawings-uses-font-glyphs=no
# dpi-aware=yes
# initial-window-size-pixels=700x500 # Or,
diff --git a/render.c b/render.c
index ddd685b6..71cec0b7 100644
--- a/render.c
+++ b/render.c
@@ -466,7 +466,9 @@ render_cell(struct terminal *term, pixman_image_t *pix,
}
if (unlikely((base >= 0x2500 && base <= 0x259f) ||
- (base >= 0x1fb00 && base <= 0x1fb3b))) {
+ (base >= 0x1fb00 && base <= 0x1fb3b)) &&
+ likely(!term->conf->box_drawings_uses_font_glyphs))
+ {
/* Box drawing characters */
size_t idx = base >= 0x1fb00 ? base - 0x1fb00 + 160 : base - 0x2500;
xassert(idx < ALEN(term->box_drawing));