aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-09-13 15:59:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-09-13 15:59:56 +0000
commit51a7e44fa295b95404cb9b9373fb9b9a44664fda (patch)
treeae2a42a206afa538e7d33ce83c6640851e7adcd0
parentconfig: log warning when new boolean tweak options have been enabled (diff)
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.
-rw-r--r--CHANGELOG.md1
-rw-r--r--config.c30
-rw-r--r--config.h1
-rw-r--r--doc/foot.ini.5.scd12
-rw-r--r--main.c2
-rw-r--r--meson.build2
6 files changed, 46 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e05fdb3..20a0a687 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/config.c b/config.c
index d80b2501..de4e24c9 100644
--- a/config.c
+++ b/config.c
@@ -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) */
diff --git a/config.h b/config.h
index 782314e6..9a897e62 100644
--- a/config.h
+++ b/config.h
@@ -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;
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index b404d716..6829b0cb 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -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.
diff --git a/main.c b/main.c
index 8ce4c7b0..192a00f0 100644
--- a/main.c
+++ b/main.c
@@ -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()) {
diff --git a/meson.build b/meson.build
index 468626d8..00a2f57c 100644
--- a/meson.build
+++ b/meson.build
@@ -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')