aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--config.c17
-rw-r--r--config.h3
-rw-r--r--doc/foot.ini.5.scd22
-rw-r--r--foot.ini1
-rw-r--r--render.c6
6 files changed, 42 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 588adf0c..b7e2f51a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -65,6 +65,8 @@
(https://codeberg.org/dnkl/foot/issues/581).
* Support for overriding configuration options on the command line
(https://codeberg.org/dnkl/foot/issues/554).
+* `underline-offset` option to `foot.ini`
+ (https://codeberg.org/dnkl/foot/issues/490).
### Changed
diff --git a/config.c b/config.c
index 0439b2e3..ae7f0be5 100644
--- a/config.c
+++ b/config.c
@@ -793,6 +793,14 @@ parse_section_main(const char *key, const char *value, struct config *conf,
return false;
}
+ else if (strcmp(key, "underline-offset") == 0) {
+ if (!str_to_pt_or_px(
+ value, &conf->underline_offset,
+ conf, path, lineno, "default", "underline-offset"))
+ return false;
+ conf->use_custom_underline_offset = true;
+ }
+
else if (strcmp(key, "dpi-aware") == 0) {
if (strcmp(value, "auto") == 0)
conf->dpi_aware = DPI_AWARE_AUTO;
@@ -2514,10 +2522,11 @@ config_load(struct config *conf, const char *conf_path,
},
.startup_mode = STARTUP_WINDOWED,
.fonts = {tll_init(), tll_init(), tll_init(), tll_init()},
- .line_height = { .pt = 0, .px = -1, },
- .letter_spacing = { .pt = 0, .px = 0, },
- .horizontal_letter_offset = {.pt = 0, .px = 0, },
- .vertical_letter_offset = {.pt = 0, .px = 0, },
+ .line_height = {.pt = 0, .px = -1},
+ .letter_spacing = {.pt = 0, .px = 0},
+ .horizontal_letter_offset = {.pt = 0, .px = 0},
+ .vertical_letter_offset = {.pt = 0, .px = 0},
+ .use_custom_underline_offset = false,
.box_drawings_uses_font_glyphs = false,
.dpi_aware = DPI_AWARE_AUTO, /* DPI-aware when scaling-factor == 1 */
.bell = {
diff --git a/config.h b/config.h
index eded3481..0e060d19 100644
--- a/config.h
+++ b/config.h
@@ -99,6 +99,9 @@ struct config {
struct pt_or_px horizontal_letter_offset;
struct pt_or_px vertical_letter_offset;
+ bool use_custom_underline_offset;
+ struct pt_or_px underline_offset;
+
bool box_drawings_uses_font_glyphs;
struct {
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index e434c84b..a34a1987 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -112,10 +112,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:
+*underline-offset*
+ Use a custom offset for underlines. The offset is, by default, in
+ _points_ and relative the font's baseline. A positive value
+ positions the underline under the baseline, while a negative value
+ positions it above the baseline.
+
+ To specify an offset in _pixels_, append *px*:
+ *underline-offset=2px*.
+
+ If left unset (the default), the offset specified in the font is
+ used, or estimated by foot if the font lacks underline positioning
+ information.
+
+ Default: _unset_.
+
+*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
dimmed down, or blurred.
diff --git a/foot.ini b/foot.ini
index 43a0306c..f2e74308 100644
--- a/foot.ini
+++ b/foot.ini
@@ -12,6 +12,7 @@
# letter-spacing=0
# horizontal-letter-offset=0
# vertical-letter-offset=0
+# underline-offset=<font metrics>
# box-drawings-uses-font-glyphs=no
# dpi-aware=yes
diff --git a/render.c b/render.c
index 68ddf5a6..bebb479a 100644
--- a/render.c
+++ b/render.c
@@ -319,7 +319,11 @@ draw_underline_with_thickness(
const pixman_color_t *color, int x, int y, int cols, int thickness)
{
/* Make sure the line isn't positioned below the cell */
- int y_ofs = font_baseline(term) - font->underline.position;
+ int y_ofs = font_baseline(term) -
+ (term->conf->use_custom_underline_offset
+ ? -term_pt_or_px_as_pixels(term, &term->conf->underline_offset)
+ : font->underline.position);
+
y_ofs = min(y_ofs, term->cell_height - thickness);
pixman_image_fill_rectangles(