add setting for strikeout thickness

This commit is contained in:
Oleh Hushchenkov 2024-08-25 11:28:21 +03:00 committed by Daniel Eklöf
parent 01fa59b6b7
commit b47a4dd255
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 32 additions and 2 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);