mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
config: add tweak.bold-text-in-bright-amount
By how much to increase the luminance when brightening bold fonts. This was previously hard-coded to a factor of 1.3, which is now the default value of the new config option. Closes #1434
This commit is contained in:
parent
e912656682
commit
f3c5b82c82
7 changed files with 35 additions and 13 deletions
|
|
@ -46,6 +46,12 @@
|
|||
|
||||
## Unreleased
|
||||
### Added
|
||||
|
||||
* `[tweak].bold-text-in-bright-amount` option ([#1434][1434]).
|
||||
|
||||
[1434]: https://codeberg.org/dnkl/foot/issues/1434
|
||||
|
||||
|
||||
### Changed
|
||||
### Deprecated
|
||||
### Removed
|
||||
|
|
|
|||
14
config.c
14
config.c
|
|
@ -480,7 +480,7 @@ value_to_dimensions(struct context *ctx, uint32_t *x, uint32_t *y)
|
|||
}
|
||||
|
||||
static bool NOINLINE
|
||||
value_to_double(struct context *ctx, float *res)
|
||||
value_to_float(struct context *ctx, float *res)
|
||||
{
|
||||
const char *s = ctx->value;
|
||||
|
||||
|
|
@ -659,7 +659,7 @@ value_to_pt_or_px(struct context *ctx, struct pt_or_px *res)
|
|||
res->px = value;
|
||||
} else {
|
||||
float value;
|
||||
if (!value_to_double(ctx, &value))
|
||||
if (!value_to_float(ctx, &value))
|
||||
return false;
|
||||
res->pt = value;
|
||||
res->px = 0;
|
||||
|
|
@ -1089,7 +1089,7 @@ parse_section_scrollback(struct context *ctx)
|
|||
}
|
||||
|
||||
else if (strcmp(key, "multiplier") == 0)
|
||||
return value_to_double(ctx, &conf->scrollback.multiplier);
|
||||
return value_to_float(ctx, &conf->scrollback.multiplier);
|
||||
|
||||
else {
|
||||
LOG_CONTEXTUAL_ERR("not a valid option: %s", key);
|
||||
|
|
@ -1298,7 +1298,7 @@ parse_section_colors(struct context *ctx)
|
|||
|
||||
else if (strcmp(key, "alpha") == 0) {
|
||||
float alpha;
|
||||
if (!value_to_double(ctx, &alpha))
|
||||
if (!value_to_float(ctx, &alpha))
|
||||
return false;
|
||||
|
||||
if (alpha < 0. || alpha > 1.) {
|
||||
|
|
@ -2461,7 +2461,7 @@ parse_section_tweak(struct context *ctx)
|
|||
}
|
||||
|
||||
else if (strcmp(key, "box-drawing-base-thickness") == 0)
|
||||
return value_to_double(ctx, &conf->tweak.box_drawing_base_thickness);
|
||||
return value_to_float(ctx, &conf->tweak.box_drawing_base_thickness);
|
||||
|
||||
else if (strcmp(key, "box-drawing-solid-shades") == 0)
|
||||
return value_to_bool(ctx, &conf->tweak.box_drawing_solid_shades);
|
||||
|
|
@ -2472,6 +2472,9 @@ parse_section_tweak(struct context *ctx)
|
|||
else if (strcmp(key, "sixel") == 0)
|
||||
return value_to_bool(ctx, &conf->tweak.sixel);
|
||||
|
||||
else if (strcmp(key, "bold-text-in-bright-amount") == 0)
|
||||
return value_to_float(ctx, &conf->bold_in_bright.amount);
|
||||
|
||||
else {
|
||||
LOG_CONTEXTUAL_ERR("not a valid option: %s", key);
|
||||
return false;
|
||||
|
|
@ -2939,6 +2942,7 @@ config_load(struct config *conf, const char *conf_path,
|
|||
.bold_in_bright = {
|
||||
.enabled = false,
|
||||
.palette_based = false,
|
||||
.amount = 1.3,
|
||||
},
|
||||
.startup_mode = STARTUP_WINDOWED,
|
||||
.fonts = {{0}},
|
||||
|
|
|
|||
1
config.h
1
config.h
|
|
@ -133,6 +133,7 @@ struct config {
|
|||
struct {
|
||||
bool enabled;
|
||||
bool palette_based;
|
||||
float amount;
|
||||
} bold_in_bright;
|
||||
|
||||
enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode;
|
||||
|
|
|
|||
|
|
@ -1337,7 +1337,13 @@ any of these options.
|
|||
Default: _512_. Maximum allowed: _2048_ (2GB).
|
||||
|
||||
*sixel*
|
||||
Boolean. When enabled, foot will process sixel images. Default: _yes_
|
||||
Boolean. When enabled, foot will process sixel images. Default:
|
||||
_yes_
|
||||
|
||||
*bold-text-in-bright-amount*
|
||||
Amount by which bold fonts are brightened when
|
||||
*bold-text-in-bright* is set to *yes* (the *palette-based* variant
|
||||
is not affected by this option). Default: _1.3_.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
|
|
|
|||
6
hsl.c
6
hsl.c
|
|
@ -83,7 +83,7 @@ hsl_to_rgb(int hue, int sat, int lum)
|
|||
b += m;
|
||||
|
||||
return (
|
||||
(int)round(r * 255.) << 16 |
|
||||
(int)round(g * 255.) << 8 |
|
||||
(int)round(b * 255.) << 0);
|
||||
(uint8_t)round(r * 255.) << 16 |
|
||||
(uint8_t)round(g * 255.) << 8 |
|
||||
(uint8_t)round(b * 255.) << 0);
|
||||
}
|
||||
|
|
|
|||
4
render.c
4
render.c
|
|
@ -299,7 +299,9 @@ color_brighten(const struct terminal *term, uint32_t color)
|
|||
|
||||
int hue, sat, lum;
|
||||
rgb_to_hsl(color, &hue, &sat, &lum);
|
||||
return hsl_to_rgb(hue, sat, min(100, lum * 1.3));
|
||||
|
||||
lum = (int)roundf(lum * term->conf->bold_in_bright.amount);
|
||||
return hsl_to_rgb(hue, sat, min(lum, 100));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ test_uint32(struct context *ctx, bool (*parse_fun)(struct context *ctx),
|
|||
}
|
||||
|
||||
static void
|
||||
test_double(struct context *ctx, bool (*parse_fun)(struct context *ctx),
|
||||
test_float(struct context *ctx, bool (*parse_fun)(struct context *ctx),
|
||||
const char *key, const float *ptr)
|
||||
{
|
||||
ctx->key = key;
|
||||
|
|
@ -580,7 +580,7 @@ test_section_scrollback(void)
|
|||
|
||||
test_uint32(&ctx, &parse_section_scrollback, "lines",
|
||||
&conf.scrollback.lines);
|
||||
test_double(&ctx, parse_section_scrollback, "multiplier", &conf.scrollback.multiplier);
|
||||
test_float(&ctx, parse_section_scrollback, "multiplier", &conf.scrollback.multiplier);
|
||||
|
||||
test_enum(
|
||||
&ctx, &parse_section_scrollback, "indicator-position",
|
||||
|
|
@ -1312,7 +1312,7 @@ test_section_tweak(void)
|
|||
RENDER_TIMER_BOTH},
|
||||
(int *)&conf.tweak.render_timer);
|
||||
|
||||
test_double(&ctx, &parse_section_tweak, "box-drawing-base-thickness",
|
||||
test_float(&ctx, &parse_section_tweak, "box-drawing-base-thickness",
|
||||
&conf.tweak.box_drawing_base_thickness);
|
||||
test_boolean(&ctx, &parse_section_tweak, "box-drawing-solid-shades",
|
||||
&conf.tweak.box_drawing_solid_shades);
|
||||
|
|
@ -1345,6 +1345,9 @@ test_section_tweak(void)
|
|||
test_boolean(&ctx, &parse_section_tweak, "font-monospace-warn",
|
||||
&conf.tweak.font_monospace_warn);
|
||||
|
||||
test_float(&ctx, &parse_section_tweak, "bold-text-in-bright-amount",
|
||||
&conf.bold_in_bright.amount);
|
||||
|
||||
#if 0 /* Must be equal to, or less than INT32_MAX */
|
||||
test_uint32(&ctx, &parse_section_tweak, "max-shm-pool-size-mb",
|
||||
&conf.tweak.max_shm_pool_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue