mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
config: remove experimental linear and merge into text-blending
This commit is contained in:
@ -264,24 +264,16 @@ const c = @cImport({
|
||||
/// This is also sometimes known as "gamma correction".
|
||||
/// (Currently only supported on macOS. Has no effect on Linux.)
|
||||
///
|
||||
/// To prevent the uneven thickness caused by linear blending, you can use
|
||||
/// the `experimental-linear-correction` option which applies a correction
|
||||
/// curve to the text alpha depending on its brightness, which compensates
|
||||
/// for the thinning and makes the weight of most text appear very similar
|
||||
/// to when it's blendeded non-linearly.
|
||||
/// * `linear-corrected` - Corrects the thinning/thickening effect of linear
|
||||
/// by applying a correction curve to the text alpha depending on its
|
||||
/// brightness. This compensates for the thinning and makes the weight of
|
||||
/// most text appear very similar to when it's blended non-linearly.
|
||||
///
|
||||
/// Note: This setting affects more than just text, images will also be blended
|
||||
/// in the selected color space, and custom shaders will receive colors in that
|
||||
/// color space as well.
|
||||
@"text-blending": TextBlending = .native,
|
||||
|
||||
/// Apply a correction curve to text alpha to compensate for uneven apparent
|
||||
/// thickness of different colors of text, roughly matching the appearance of
|
||||
/// text rendered with non-linear blending.
|
||||
///
|
||||
/// Has no effect if not using linear `text-blending`.
|
||||
@"experimental-linear-correction": bool = false,
|
||||
|
||||
/// All of the configurations behavior adjust various metrics determined by the
|
||||
/// font. The values can be integers (1, -1, etc.) or a percentage (20%, -15%,
|
||||
/// etc.). In each case, the values represent the amount to change the original
|
||||
@ -5787,6 +5779,14 @@ pub const GraphemeWidthMethod = enum {
|
||||
pub const TextBlending = enum {
|
||||
native,
|
||||
linear,
|
||||
@"linear-corrected",
|
||||
|
||||
pub fn isLinear(self: TextBlending) bool {
|
||||
return switch (self) {
|
||||
.native => false,
|
||||
.linear, .@"linear-corrected" => true,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/// See freetype-load-flag
|
||||
|
@ -389,7 +389,6 @@ pub const DerivedConfig = struct {
|
||||
vsync: bool,
|
||||
colorspace: configpkg.Config.WindowColorspace,
|
||||
blending: configpkg.Config.TextBlending,
|
||||
experimental_linear_correction: bool,
|
||||
|
||||
pub fn init(
|
||||
alloc_gpa: Allocator,
|
||||
@ -462,8 +461,6 @@ pub const DerivedConfig = struct {
|
||||
.vsync = config.@"window-vsync",
|
||||
.colorspace = config.@"window-colorspace",
|
||||
.blending = config.@"text-blending",
|
||||
.experimental_linear_correction = config.@"text-blending" == .linear and config.@"experimental-linear-correction",
|
||||
|
||||
.arena = arena,
|
||||
};
|
||||
}
|
||||
@ -559,7 +556,7 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
||||
// the pixels written to it *after* blending, which means
|
||||
// we get linear alpha blending rather than gamma-incorrect
|
||||
// blending.
|
||||
if (options.config.blending == .linear)
|
||||
if (options.config.blending.isLinear())
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||
else
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||
@ -655,8 +652,8 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
||||
},
|
||||
.cursor_wide = false,
|
||||
.use_display_p3 = options.config.colorspace == .@"display-p3",
|
||||
.use_linear_blending = options.config.blending == .linear,
|
||||
.use_experimental_linear_correction = options.config.experimental_linear_correction,
|
||||
.use_linear_blending = options.config.blending.isLinear(),
|
||||
.use_experimental_linear_correction = options.config.blending == .@"linear-corrected",
|
||||
},
|
||||
|
||||
// Fonts
|
||||
@ -774,7 +771,7 @@ fn initShaders(self: *Metal) !void {
|
||||
// the pixels written to it *after* blending, which means
|
||||
// we get linear alpha blending rather than gamma-incorrect
|
||||
// blending.
|
||||
if (self.config.blending == .linear)
|
||||
if (self.config.blending.isLinear())
|
||||
mtl.MTLPixelFormat.bgra8unorm_srgb
|
||||
else
|
||||
mtl.MTLPixelFormat.bgra8unorm,
|
||||
@ -2071,9 +2068,8 @@ pub fn changeConfig(self: *Metal, config: *DerivedConfig) !void {
|
||||
|
||||
// Set our new color space and blending
|
||||
self.uniforms.use_display_p3 = config.colorspace == .@"display-p3";
|
||||
self.uniforms.use_linear_blending = config.blending == .linear;
|
||||
|
||||
self.uniforms.use_experimental_linear_correction = config.experimental_linear_correction;
|
||||
self.uniforms.use_linear_blending = config.blending.isLinear();
|
||||
self.uniforms.use_experimental_linear_correction = config.blending == .@"linear-corrected";
|
||||
|
||||
// Set our new colors
|
||||
self.default_background_color = config.background;
|
||||
@ -2105,7 +2101,7 @@ pub fn changeConfig(self: *Metal, config: *DerivedConfig) !void {
|
||||
// And we update our layer's pixel format appropriately.
|
||||
self.layer.setProperty(
|
||||
"pixelFormat",
|
||||
if (config.blending == .linear)
|
||||
if (config.blending.isLinear())
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||
else
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||
@ -2231,7 +2227,7 @@ pub fn setScreenSize(
|
||||
// the pixels written to it *after* blending, which means
|
||||
// we get linear alpha blending rather than gamma-incorrect
|
||||
// blending.
|
||||
if (self.config.blending == .linear)
|
||||
if (self.config.blending.isLinear())
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||
else
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||
@ -2271,7 +2267,7 @@ pub fn setScreenSize(
|
||||
// the pixels written to it *after* blending, which means
|
||||
// we get linear alpha blending rather than gamma-incorrect
|
||||
// blending.
|
||||
if (self.config.blending == .linear)
|
||||
if (self.config.blending.isLinear())
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||
else
|
||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||
|
Reference in New Issue
Block a user