From 1ea20b1b707ded204e6239f2704ae97ec9cd8852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 26 Apr 2025 10:41:14 +0200 Subject: [PATCH 1/5] changelog: add new 'unreleased' section --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeabbe14..3c48c41c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.22.1](#1-22-1) * [1.22.0](#1-22-0) * [1.21.0](#1-21-0) @@ -60,6 +61,16 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Contributors + + ## 1.22.1 ### Fixed From ce424e0990f9bf20995cfde36f3ec635512d64fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 27 Apr 2025 10:14:45 +0200 Subject: [PATCH 2/5] scripts: srgb: use 2.2 gamma TF instead of piece-wise sRGB TF --- CHANGELOG.md | 15 +++++++++++++++ scripts/srgb.py | 29 +++++------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c48c41c..645c6c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,9 +64,24 @@ ## Unreleased ### Added ### Changed + +* `gamma-correct-blending=yes` now uses a pure gamma 2.2 transfer + function, instead of the piece-wise sRGB transfer function, to match + what compositors do. + + ### Deprecated ### Removed ### Fixed + +* Wrong colors when `gamma-correct-blending=yes` (the default when + there is compositor support). Note that some colors will still be + off by a **very** small amount, due to loss of precision when + converting to a linear color space. ([#2035][2035]). + +[2035]: https://codeberg.org/dnkl/foot/issues/2035 + + ### Security ### Contributors diff --git a/scripts/srgb.py b/scripts/srgb.py index 7655dbe4..12056956 100755 --- a/scripts/srgb.py +++ b/scripts/srgb.py @@ -5,21 +5,16 @@ import math import sys +# Note: we use a pure gamma 2.2 function, rather than the piece-wise +# sRGB transfer function, since that is what all compositors do. + def srgb_to_linear(f: float) -> float: assert(f >= 0 and f <= 1.0) - - if f <= 0.04045: - return f / 12.92 - - return math.pow((f + 0.055) / 1.055, 2.4) + return math.pow(f, 2.2) def linear_to_srgb(f: float) -> float: - if f < 0.0031308: - return f * 12.92 - - return 1.055 * math.pow(f, 1 / 2.4) - 0.055 - + return math.pow(f, 1 / 2.2) def main(): @@ -29,24 +24,10 @@ def main(): opts = parser.parse_args() linear_table: list[int] = [] - srgb_table: list[int] = [] for i in range(256): linear_table.append(int(srgb_to_linear(float(i) / 255) * 65535 + 0.5)) - for i in range(4096): - srgb_table.append(int(linear_to_srgb(float(i) / 4095) * 255 + 0.5)) - - for i in range(256): - while True: - linear = linear_table[i] - srgb = srgb_table[linear >> 4] - - if i == srgb: - break - - linear_table[i] += 1 - opts.h_output.write("#pragma once\n") opts.h_output.write("#include \n") From 172f67a8df71d859e3f610dabffabff0623775a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 28 Apr 2025 12:32:40 +0200 Subject: [PATCH 3/5] doc: foot.ini: gamma-correct: tweak wording of 8- vs. 10-bit surfaces --- doc/foot.ini.5.scd | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index cffbf9c5..95e491eb 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -220,11 +220,12 @@ empty string to be set, but it must be quoted: *KEY=""*) than intended when rendered with gamma-correct blending, since the font designer set the font weight based on incorrect rendering. - Note that some colors (especially dark ones) will look a bit + Note that some colors (especially dark ones) may be slightly off. The reason for this is loss of color precision, due to foot - using 8-bit surfaces (i.e. each color channel is 8 bits). The - amount of errors can be reduced by using 10-bit surfaces; see - *tweak.surface-bit-depth*. + using 8-bit surfaces (i.e. each color channel is 8 bits). In all + known cases, the difference is small enough not to be noticed + though. The amount of errors can be reduced by using 10-bit + surfaces; see *tweak.surface-bit-depth*. Default: enabled when compositor support is available From fc293bad5e3989a7aef778ad8d0dc054794a990c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 30 Apr 2025 10:23:20 +0200 Subject: [PATCH 4/5] changelog: prepare 1.22.2 --- CHANGELOG.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 645c6c38..8ef3ae43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -* [Unreleased](#unreleased) +* [1.22.2](#1-22-2) * [1.22.1](#1-22-1) * [1.22.0](#1-22-0) * [1.21.0](#1-21-0) @@ -61,8 +61,8 @@ * [1.2.0](#1-2-0) -## Unreleased -### Added +## 1.22.2 + ### Changed * `gamma-correct-blending=yes` now uses a pure gamma 2.2 transfer @@ -70,8 +70,6 @@ what compositors do. -### Deprecated -### Removed ### Fixed * Wrong colors when `gamma-correct-blending=yes` (the default when @@ -82,10 +80,6 @@ [2035]: https://codeberg.org/dnkl/foot/issues/2035 -### Security -### Contributors - - ## 1.22.1 ### Fixed From 513e91c33a0b1593f80b887e42c38ef4ba981634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 30 Apr 2025 10:23:51 +0200 Subject: [PATCH 5/5] meson: bump version to 1.22.2 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 7ac033b5..b3163586 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('foot', 'c', - version: '1.22.1', + version: '1.22.2', license: 'MIT', meson_version: '>=0.59.0', default_options: [