mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
add setting for strikeout thickness
This commit is contained in:
parent
01fa59b6b7
commit
b47a4dd255
6 changed files with 32 additions and 2 deletions
4
config.c
4
config.c
|
|
@ -1023,6 +1023,9 @@ parse_section_main(struct context *ctx)
|
||||||
else if (streq(key, "underline-thickness"))
|
else if (streq(key, "underline-thickness"))
|
||||||
return value_to_pt_or_px(ctx, &conf->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"))
|
else if (streq(key, "dpi-aware"))
|
||||||
return value_to_bool(ctx, &conf->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,
|
.use_custom_underline_offset = false,
|
||||||
.box_drawings_uses_font_glyphs = false,
|
.box_drawings_uses_font_glyphs = false,
|
||||||
.underline_thickness = {.pt = 0., .px = -1},
|
.underline_thickness = {.pt = 0., .px = -1},
|
||||||
|
.strikeout_thickness = {.pt = 0., .px = -1},
|
||||||
.dpi_aware = false,
|
.dpi_aware = false,
|
||||||
.bell = {
|
.bell = {
|
||||||
.urgent = false,
|
.urgent = false,
|
||||||
|
|
|
||||||
2
config.h
2
config.h
|
|
@ -168,6 +168,8 @@ struct config {
|
||||||
struct pt_or_px underline_offset;
|
struct pt_or_px underline_offset;
|
||||||
struct pt_or_px underline_thickness;
|
struct pt_or_px underline_thickness;
|
||||||
|
|
||||||
|
struct pt_or_px strikeout_thickness;
|
||||||
|
|
||||||
bool box_drawings_uses_font_glyphs;
|
bool box_drawings_uses_font_glyphs;
|
||||||
bool can_shape_grapheme;
|
bool can_shape_grapheme;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,18 @@ empty string to be set, but it must be quoted: *KEY=""*)
|
||||||
|
|
||||||
Default: _unset_
|
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*
|
*box-drawings-uses-font-glyphs*
|
||||||
Boolean. When disabled, foot generates box/line drawing characters
|
Boolean. When disabled, foot generates box/line drawing characters
|
||||||
itself. The are several advantages to doing this instead of using
|
itself. The are several advantages to doing this instead of using
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -19,6 +19,7 @@
|
||||||
# vertical-letter-offset=0
|
# vertical-letter-offset=0
|
||||||
# underline-offset=<font metrics>
|
# underline-offset=<font metrics>
|
||||||
# underline-thickness=<font underline thickness>
|
# underline-thickness=<font underline thickness>
|
||||||
|
# strikeout-thickness=<font strikeout thickness>
|
||||||
# box-drawings-uses-font-glyphs=no
|
# box-drawings-uses-font-glyphs=no
|
||||||
# dpi-aware=no
|
# dpi-aware=no
|
||||||
|
|
||||||
|
|
|
||||||
14
render.c
14
render.c
|
|
@ -544,11 +544,21 @@ draw_strikeout(const struct terminal *term, pixman_image_t *pix,
|
||||||
const struct fcft_font *font,
|
const struct fcft_font *font,
|
||||||
const pixman_color_t *color, int x, int y, int cols)
|
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_image_fill_rectangles(
|
||||||
PIXMAN_OP_SRC, pix, color,
|
PIXMAN_OP_SRC, pix, color,
|
||||||
1, &(pixman_rectangle16_t){
|
1, &(pixman_rectangle16_t){
|
||||||
x, y + term->font_baseline - font->strikeout.position,
|
x, y + term->font_baseline - position,
|
||||||
cols * term->cell_width, font->strikeout.thickness});
|
cols * term->cell_width, thickness});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -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, "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, "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, "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, "resize-delay-ms", &conf.resize_delay_ms);
|
||||||
test_uint16(&ctx, &parse_section_main, "workers", &conf.render_worker_count);
|
test_uint16(&ctx, &parse_section_main, "workers", &conf.render_worker_count);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue