mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-29 06:46:35 -04:00
Add option to enable subpixel font rendering with transparent background
This commit is contained in:
parent
029920ddcc
commit
aeac5ad6f1
5 changed files with 13 additions and 2 deletions
4
config.c
4
config.c
|
|
@ -961,6 +961,9 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
else if (strcmp(key, "box-drawings-uses-font-glyphs") == 0)
|
else if (strcmp(key, "box-drawings-uses-font-glyphs") == 0)
|
||||||
conf->box_drawings_uses_font_glyphs = str_to_bool(value);
|
conf->box_drawings_uses_font_glyphs = str_to_bool(value);
|
||||||
|
|
||||||
|
else if (strcmp(key, "subpixel-with-alpha") == 0)
|
||||||
|
conf->subpixel_with_alpha = str_to_bool(value);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
LOG_AND_NOTIFY_ERR("%s:%u: [default]: %s: invalid key", path, lineno, key);
|
LOG_AND_NOTIFY_ERR("%s:%u: [default]: %s: invalid key", path, lineno, key);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2740,6 +2743,7 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
.vertical_letter_offset = {.pt = 0, .px = 0},
|
.vertical_letter_offset = {.pt = 0, .px = 0},
|
||||||
.use_custom_underline_offset = false,
|
.use_custom_underline_offset = false,
|
||||||
.box_drawings_uses_font_glyphs = false,
|
.box_drawings_uses_font_glyphs = false,
|
||||||
|
.subpixel_with_alpha = false,
|
||||||
.dpi_aware = DPI_AWARE_AUTO, /* DPI-aware when scaling-factor == 1 */
|
.dpi_aware = DPI_AWARE_AUTO, /* DPI-aware when scaling-factor == 1 */
|
||||||
.bell = {
|
.bell = {
|
||||||
.urgent = false,
|
.urgent = false,
|
||||||
|
|
|
||||||
2
config.h
2
config.h
|
|
@ -114,6 +114,8 @@ struct config {
|
||||||
bool box_drawings_uses_font_glyphs;
|
bool box_drawings_uses_font_glyphs;
|
||||||
bool can_shape_grapheme;
|
bool can_shape_grapheme;
|
||||||
|
|
||||||
|
bool subpixel_with_alpha;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool urgent;
|
bool urgent;
|
||||||
bool notify;
|
bool notify;
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,10 @@ in this order:
|
||||||
|
|
||||||
Default: _no_.
|
Default: _no_.
|
||||||
|
|
||||||
|
*subpixel-with-alpha*
|
||||||
|
Boolean. When enabled, subpixel font rendering will be used also
|
||||||
|
with transparent background. Default: _no_.
|
||||||
|
|
||||||
*dpi-aware*
|
*dpi-aware*
|
||||||
*auto*, *yes*, or *no*. When set to *yes*, fonts are sized using
|
*auto*, *yes*, or *no*. When set to *yes*, fonts are sized using
|
||||||
the monitor's DPI, making a font of a given size have the same
|
the monitor's DPI, making a font of a given size have the same
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -19,6 +19,7 @@
|
||||||
# underline-offset=<font metrics>
|
# underline-offset=<font metrics>
|
||||||
# box-drawings-uses-font-glyphs=no
|
# box-drawings-uses-font-glyphs=no
|
||||||
# dpi-aware=yes
|
# dpi-aware=yes
|
||||||
|
# subpixel-with-alpha=no
|
||||||
|
|
||||||
# initial-window-size-pixels=700x500 # Or,
|
# initial-window-size-pixels=700x500 # Or,
|
||||||
# initial-window-size-chars=<COLSxROWS>
|
# initial-window-size-chars=<COLSxROWS>
|
||||||
|
|
|
||||||
|
|
@ -760,7 +760,7 @@ get_font_dpi(const struct terminal *term)
|
||||||
static enum fcft_subpixel
|
static enum fcft_subpixel
|
||||||
get_font_subpixel(const struct terminal *term)
|
get_font_subpixel(const struct terminal *term)
|
||||||
{
|
{
|
||||||
if (term->colors.alpha != 0xffff) {
|
if (!term->conf->subpixel_with_alpha && term->colors.alpha != 0xffff) {
|
||||||
/* Can't do subpixel rendering on transparent background */
|
/* Can't do subpixel rendering on transparent background */
|
||||||
return FCFT_SUBPIXEL_NONE;
|
return FCFT_SUBPIXEL_NONE;
|
||||||
}
|
}
|
||||||
|
|
@ -1086,7 +1086,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
xmalloc(sizeof(term->font_sizes[3][0]) * conf->fonts[3].count),
|
xmalloc(sizeof(term->font_sizes[3][0]) * conf->fonts[3].count),
|
||||||
},
|
},
|
||||||
.font_dpi = 0.,
|
.font_dpi = 0.,
|
||||||
.font_subpixel = (conf->colors.alpha == 0xffff /* Can't do subpixel rendering on transparent background */
|
.font_subpixel = ((conf->subpixel_with_alpha || conf->colors.alpha == 0xffff) /* Can't do subpixel rendering on transparent background */
|
||||||
? FCFT_SUBPIXEL_DEFAULT
|
? FCFT_SUBPIXEL_DEFAULT
|
||||||
: FCFT_SUBPIXEL_NONE),
|
: FCFT_SUBPIXEL_NONE),
|
||||||
.cursor_keys_mode = CURSOR_KEYS_NORMAL,
|
.cursor_keys_mode = CURSOR_KEYS_NORMAL,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue