mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-08 10:06:22 -05:00
Add curly-pixelated option for blocky undercurl style
Adds a new boolean option `curly-pixelated` that renders undercurls as alternating 4px blocks instead of smooth trapezoids. This style works better with bitmap/monospace fonts like GohuFont. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
6fbb9b7d3b
commit
ba4d66e3bb
4 changed files with 28 additions and 0 deletions
4
config.c
4
config.c
|
|
@ -1075,6 +1075,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, "curly-pixelated"))
|
||||
return value_to_bool(ctx, &conf->curly_pixelated);
|
||||
|
||||
else if (streq(key, "strikeout-thickness"))
|
||||
return value_to_pt_or_px(ctx, &conf->strikeout_thickness);
|
||||
|
||||
|
|
@ -3475,6 +3478,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},
|
||||
.curly_pixelated = false,
|
||||
.strikeout_thickness = {.pt = 0., .px = -1},
|
||||
.dpi_aware = false,
|
||||
.gamma_correct = false,
|
||||
|
|
|
|||
1
config.h
1
config.h
|
|
@ -270,6 +270,7 @@ struct config {
|
|||
bool use_custom_underline_offset;
|
||||
struct pt_or_px underline_offset;
|
||||
struct pt_or_px underline_thickness;
|
||||
bool curly_pixelated;
|
||||
|
||||
struct pt_or_px strikeout_thickness;
|
||||
|
||||
|
|
|
|||
|
|
@ -186,6 +186,12 @@ empty string to be set, but it must be quoted: *KEY=""*)
|
|||
|
||||
Default: _unset_
|
||||
|
||||
*curly-pixelated*
|
||||
Render curly underlines as alternating 4px blocks instead of smooth
|
||||
trapezoids. This style works better with bitmap/monospace fonts.
|
||||
|
||||
Default: _no_
|
||||
|
||||
*strikeout-thickness*
|
||||
Use a custom thickness (height) for strikeouts. The thickness is, by
|
||||
default, in _points_.
|
||||
|
|
|
|||
17
render.c
17
render.c
|
|
@ -524,6 +524,23 @@ draw_styled_underline(const struct terminal *term, pixman_image_t *pix,
|
|||
}
|
||||
|
||||
case UNDERLINE_CURLY: {
|
||||
if (term->conf->curly_pixelated) {
|
||||
/* Pixelated curly: 4px blocks alternating rows */
|
||||
const int y_top = y + underline_offset(term, font);
|
||||
const int y_bot = y_top + thickness;
|
||||
for (int bx = x; bx < x + ceil_w; bx += 8) {
|
||||
int w1 = min(4, x + ceil_w - bx);
|
||||
int w2 = min(4, x + ceil_w - bx - 4);
|
||||
if (w1 > 0)
|
||||
pixman_image_fill_rectangles(PIXMAN_OP_SRC, pix, color, 1,
|
||||
&(pixman_rectangle16_t){bx, y_top, w1, thickness});
|
||||
if (w2 > 0)
|
||||
pixman_image_fill_rectangles(PIXMAN_OP_SRC, pix, color, 1,
|
||||
&(pixman_rectangle16_t){bx + 4, y_bot, w2, thickness});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const int top = y + y_ofs;
|
||||
const int bot = top + thickness * 3;
|
||||
const int half_x = x + ceil_w / 2.0, full_x = x + ceil_w;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue