Merge branch 'underline-positioning'

Closes #490
This commit is contained in:
Daniel Eklöf 2021-06-18 15:32:51 +02:00
commit 26b0e3d441
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 42 additions and 9 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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