aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleh Hushchenkov <o.hushchenkov@gmail.com>2024-08-25 08:28:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-08-26 17:34:47 +0000
commitb47a4dd2553b7f4db5a385b15bc7cb559c9932db (patch)
tree23a26267d7f84d34f1674244e6ce4523e3640418
parentchangelog: mbsntoc32() failure checks (diff)
add setting for strikeout thickness
-rw-r--r--config.c4
-rw-r--r--config.h2
-rw-r--r--doc/foot.ini.5.scd12
-rw-r--r--foot.ini1
-rw-r--r--render.c14
-rw-r--r--tests/test-config.c1
6 files changed, 32 insertions, 2 deletions
diff --git a/config.c b/config.c
index a80a26b4..bda7648b 100644
--- a/config.c
+++ b/config.c
@@ -1023,6 +1023,9 @@ parse_section_main(struct context *ctx)
else if (streq(key, "underline-thickness"))
return value_to_pt_or_px(ctx, &conf->underline_thickness);
+ else if (streq(key, "strikeout-thickness"))
+ return value_to_pt_or_px(ctx, &conf->strikeout_thickness);
+
else if (streq(key, "dpi-aware"))
return value_to_bool(ctx, &conf->dpi_aware);
@@ -3121,6 +3124,7 @@ config_load(struct config *conf, const char *conf_path,
.use_custom_underline_offset = false,
.box_drawings_uses_font_glyphs = false,
.underline_thickness = {.pt = 0., .px = -1},
+ .strikeout_thickness = {.pt = 0., .px = -1},
.dpi_aware = false,
.bell = {
.urgent = false,
diff --git a/config.h b/config.h
index be99987b..9e983011 100644
--- a/config.h
+++ b/config.h
@@ -168,6 +168,8 @@ struct config {
struct pt_or_px underline_offset;
struct pt_or_px underline_thickness;
+ struct pt_or_px strikeout_thickness;
+
bool box_drawings_uses_font_glyphs;
bool can_shape_grapheme;
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index 47c5939e..908eb25f 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -179,6 +179,18 @@ empty string to be set, but it must be quoted: *KEY=""*)
Default: _unset_
+*strikeout-thickness*
+ Use a custom thickness (height) for strikeouts. The thickness is, by
+ default, in _points_.
+
+ To specify a thickness in _pixels_, append *px*:
+ *strikeout-thickness=1px*.
+
+ If left unset (the default), the thickness specified in the font is
+ used.
+
+ 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
diff --git a/foot.ini b/foot.ini
index c2c80fa3..6ad2085f 100644
--- a/foot.ini
+++ b/foot.ini
@@ -19,6 +19,7 @@
# vertical-letter-offset=0
# underline-offset=<font metrics>
# underline-thickness=<font underline thickness>
+# strikeout-thickness=<font strikeout thickness>
# box-drawings-uses-font-glyphs=no
# dpi-aware=no
diff --git a/render.c b/render.c
index d9317b68..98bc0b69 100644
--- a/render.c
+++ b/render.c
@@ -544,11 +544,21 @@ draw_strikeout(const struct terminal *term, pixman_image_t *pix,
const struct fcft_font *font,
const pixman_color_t *color, int x, int y, int cols)
{
+ const int thickness = term->conf->strikeout_thickness.px >= 0
+ ? term_pt_or_px_as_pixels(
+ term, &term->conf->strikeout_thickness)
+ : font->strikeout.thickness;
+
+ /* Try to center custom strikeout */
+ const int position = term->conf->strikeout_thickness.px >= 0
+ ? font->strikeout.position - round(font->strikeout.thickness / 2.) + round(thickness / 2.)
+ : font->strikeout.position;
+
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, pix, color,
1, &(pixman_rectangle16_t){
- x, y + term->font_baseline - font->strikeout.position,
- cols * term->cell_width, font->strikeout.thickness});
+ x, y + term->font_baseline - position,
+ cols * term->cell_width, thickness});
}
static void
diff --git a/tests/test-config.c b/tests/test-config.c
index a41e8536..61999686 100644
--- a/tests/test-config.c
+++ b/tests/test-config.c
@@ -520,6 +520,7 @@ test_section_main(void)
test_pt_or_px(&ctx, &parse_section_main, "horizontal-letter-offset", &conf.horizontal_letter_offset);
test_pt_or_px(&ctx, &parse_section_main, "vertical-letter-offset", &conf.vertical_letter_offset);
test_pt_or_px(&ctx, &parse_section_main, "underline-thickness", &conf.underline_thickness);
+ test_pt_or_px(&ctx, &parse_section_main, "strikeout-thickness", &conf.strikeout_thickness);
test_uint16(&ctx, &parse_section_main, "resize-delay-ms", &conf.resize_delay_ms);
test_uint16(&ctx, &parse_section_main, "workers", &conf.render_worker_count);