config: add tweak.scaling-filter

Use the new fcft_set_scaling_filter() API to use a non-default scaling
filter.

By default, we use lanczo3, the ‘best’ filter. This overrides the
default in fcft, which is ‘cubic’ filtering.
This commit is contained in:
Daniel Eklöf 2020-09-13 17:59:56 +02:00
parent 6a9725c7a6
commit 51a7e44fa2
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 46 additions and 2 deletions

View file

@ -91,6 +91,7 @@
* Minimum window size changed from four rows and 20 columns, to 1 row
and 2 columns.
* **scrollback-up/down** renamed to **scrollback-up/down-page**.
* fcft >= 2.3.0 is now required.
### Fixed

View file

@ -1442,7 +1442,34 @@ parse_section_tweak(
const char *key, const char *value, struct config *conf,
const char *path, unsigned lineno)
{
if (strcmp(key, "allow-overflowing-double-width-glyphs") == 0) {
if (strcmp(key, "scaling-filter") == 0) {
static const struct {
const char *name;
enum fcft_scaling_filter filter;
} filters[] = {
{"none", FCFT_SCALING_FILTER_NONE},
{"nearest", FCFT_SCALING_FILTER_NEAREST},
{"bilinear", FCFT_SCALING_FILTER_BILINEAR},
{"cubic", FCFT_SCALING_FILTER_CUBIC},
{"lanczos3", FCFT_SCALING_FILTER_LANCZOS3},
};
for (size_t i = 0; i < ALEN(filters); i++) {
if (strcmp(value, filters[i].name) == 0) {
conf->tweak.fcft_filter = filters[i].filter;
LOG_WARN("tweak: scaling-filter=%s", filters[i].name);
return true;
}
}
LOG_AND_NOTIFY_ERR(
"%s:%d: [tweak]: %s: invalid 'scaling-filter' value, "
"expected one of 'none', 'nearest', 'bilinear', 'cubic' or "
"'lanczos3'", path, lineno, value);
return false;
}
else if (strcmp(key, "allow-overflowing-double-width-glyphs") == 0) {
conf->tweak.allow_overflowing_double_width_glyphs = str_to_bool(value);
if (conf->tweak.allow_overflowing_double_width_glyphs)
LOG_WARN("tweak: allow overflowing double-width glyphs");
@ -1894,6 +1921,7 @@ config_load(struct config *conf, const char *conf_path,
.hold_at_exit = false,
.tweak = {
.fcft_filter = FCFT_SCALING_FILTER_LANCZOS3,
.allow_overflowing_double_width_glyphs = false,
.delayed_render_lower_ns = 500000, /* 0.5ms */
.delayed_render_upper_ns = 16666666 / 2, /* half a frame period (60Hz) */

View file

@ -160,6 +160,7 @@ struct config {
bool hold_at_exit;
struct {
enum fcft_scaling_filter fcft_filter;
bool allow_overflowing_double_width_glyphs;
bool render_timer_osd;
bool render_timer_log;

View file

@ -460,9 +460,21 @@ should not change these unless you understand what they do and note
that changing the default values *will* print a warning when launching
foot.
Note that these options may change, or be removed at any time, without
prior notice.
When reporting bugs, please mention if, and to what, you have changed
any of these options.
*scaling-filter*
Overrides the default scaling filter used when down-scaling bitmap
fonts (e.g. emoji fonts). Possible values are *none*, *nearest*,
*bilinear*, *cubic* or *lanczos3*. *cubic* and *lanczos3* produce
the best results, but are slower (with *lanczos3* being the best
_and_ slowest).
Default: _lanczos3_.
*allow-overflowing-double-width-glyphs*
Boolean. when enabled, double width glyphs with a character width
of 1 are allowed to overflow into the neighbouring cell.

2
main.c
View file

@ -363,6 +363,8 @@ main(int argc, char *const *argv)
return EXIT_SUCCESS;
}
fcft_set_scaling_filter(conf.tweak.fcft_filter);
setlocale(LC_CTYPE, "");
LOG_INFO("locale: %s", setlocale(LC_CTYPE, NULL));
if (!locale_is_utf8()) {

View file

@ -62,7 +62,7 @@ xkb = dependency('xkbcommon')
fontconfig = dependency('fontconfig')
tllist = dependency('tllist', version: '>=1.0.4', fallback: 'tllist')
fcft = dependency('fcft', version: ['>=2.2.2', '<3.0.0'], fallback: 'fcft')
fcft = dependency('fcft', version: ['>=2.3.0', '<3.0.0'], fallback: 'fcft')
wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir')