mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +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".
|
/// This is also sometimes known as "gamma correction".
|
||||||
/// (Currently only supported on macOS. Has no effect on Linux.)
|
/// (Currently only supported on macOS. Has no effect on Linux.)
|
||||||
///
|
///
|
||||||
/// To prevent the uneven thickness caused by linear blending, you can use
|
/// * `linear-corrected` - Corrects the thinning/thickening effect of linear
|
||||||
/// the `experimental-linear-correction` option which applies a correction
|
/// by applying a correction curve to the text alpha depending on its
|
||||||
/// curve to the text alpha depending on its brightness, which compensates
|
/// brightness. This compensates for the thinning and makes the weight of
|
||||||
/// for the thinning and makes the weight of most text appear very similar
|
/// most text appear very similar to when it's blended non-linearly.
|
||||||
/// to when it's blendeded non-linearly.
|
|
||||||
///
|
///
|
||||||
/// Note: This setting affects more than just text, images will also be blended
|
/// 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
|
/// in the selected color space, and custom shaders will receive colors in that
|
||||||
/// color space as well.
|
/// color space as well.
|
||||||
@"text-blending": TextBlending = .native,
|
@"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
|
/// 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%,
|
/// 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
|
/// 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 {
|
pub const TextBlending = enum {
|
||||||
native,
|
native,
|
||||||
linear,
|
linear,
|
||||||
|
@"linear-corrected",
|
||||||
|
|
||||||
|
pub fn isLinear(self: TextBlending) bool {
|
||||||
|
return switch (self) {
|
||||||
|
.native => false,
|
||||||
|
.linear, .@"linear-corrected" => true,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// See freetype-load-flag
|
/// See freetype-load-flag
|
||||||
|
@ -389,7 +389,6 @@ pub const DerivedConfig = struct {
|
|||||||
vsync: bool,
|
vsync: bool,
|
||||||
colorspace: configpkg.Config.WindowColorspace,
|
colorspace: configpkg.Config.WindowColorspace,
|
||||||
blending: configpkg.Config.TextBlending,
|
blending: configpkg.Config.TextBlending,
|
||||||
experimental_linear_correction: bool,
|
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
alloc_gpa: Allocator,
|
alloc_gpa: Allocator,
|
||||||
@ -462,8 +461,6 @@ pub const DerivedConfig = struct {
|
|||||||
.vsync = config.@"window-vsync",
|
.vsync = config.@"window-vsync",
|
||||||
.colorspace = config.@"window-colorspace",
|
.colorspace = config.@"window-colorspace",
|
||||||
.blending = config.@"text-blending",
|
.blending = config.@"text-blending",
|
||||||
.experimental_linear_correction = config.@"text-blending" == .linear and config.@"experimental-linear-correction",
|
|
||||||
|
|
||||||
.arena = arena,
|
.arena = arena,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -559,7 +556,7 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
|||||||
// the pixels written to it *after* blending, which means
|
// the pixels written to it *after* blending, which means
|
||||||
// we get linear alpha blending rather than gamma-incorrect
|
// we get linear alpha blending rather than gamma-incorrect
|
||||||
// blending.
|
// blending.
|
||||||
if (options.config.blending == .linear)
|
if (options.config.blending.isLinear())
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||||
else
|
else
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||||
@ -655,8 +652,8 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
|||||||
},
|
},
|
||||||
.cursor_wide = false,
|
.cursor_wide = false,
|
||||||
.use_display_p3 = options.config.colorspace == .@"display-p3",
|
.use_display_p3 = options.config.colorspace == .@"display-p3",
|
||||||
.use_linear_blending = options.config.blending == .linear,
|
.use_linear_blending = options.config.blending.isLinear(),
|
||||||
.use_experimental_linear_correction = options.config.experimental_linear_correction,
|
.use_experimental_linear_correction = options.config.blending == .@"linear-corrected",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
@ -774,7 +771,7 @@ fn initShaders(self: *Metal) !void {
|
|||||||
// the pixels written to it *after* blending, which means
|
// the pixels written to it *after* blending, which means
|
||||||
// we get linear alpha blending rather than gamma-incorrect
|
// we get linear alpha blending rather than gamma-incorrect
|
||||||
// blending.
|
// blending.
|
||||||
if (self.config.blending == .linear)
|
if (self.config.blending.isLinear())
|
||||||
mtl.MTLPixelFormat.bgra8unorm_srgb
|
mtl.MTLPixelFormat.bgra8unorm_srgb
|
||||||
else
|
else
|
||||||
mtl.MTLPixelFormat.bgra8unorm,
|
mtl.MTLPixelFormat.bgra8unorm,
|
||||||
@ -2071,9 +2068,8 @@ pub fn changeConfig(self: *Metal, config: *DerivedConfig) !void {
|
|||||||
|
|
||||||
// Set our new color space and blending
|
// Set our new color space and blending
|
||||||
self.uniforms.use_display_p3 = config.colorspace == .@"display-p3";
|
self.uniforms.use_display_p3 = config.colorspace == .@"display-p3";
|
||||||
self.uniforms.use_linear_blending = config.blending == .linear;
|
self.uniforms.use_linear_blending = config.blending.isLinear();
|
||||||
|
self.uniforms.use_experimental_linear_correction = config.blending == .@"linear-corrected";
|
||||||
self.uniforms.use_experimental_linear_correction = config.experimental_linear_correction;
|
|
||||||
|
|
||||||
// Set our new colors
|
// Set our new colors
|
||||||
self.default_background_color = config.background;
|
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.
|
// And we update our layer's pixel format appropriately.
|
||||||
self.layer.setProperty(
|
self.layer.setProperty(
|
||||||
"pixelFormat",
|
"pixelFormat",
|
||||||
if (config.blending == .linear)
|
if (config.blending.isLinear())
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||||
else
|
else
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||||
@ -2231,7 +2227,7 @@ pub fn setScreenSize(
|
|||||||
// the pixels written to it *after* blending, which means
|
// the pixels written to it *after* blending, which means
|
||||||
// we get linear alpha blending rather than gamma-incorrect
|
// we get linear alpha blending rather than gamma-incorrect
|
||||||
// blending.
|
// blending.
|
||||||
if (self.config.blending == .linear)
|
if (self.config.blending.isLinear())
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||||
else
|
else
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||||
@ -2271,7 +2267,7 @@ pub fn setScreenSize(
|
|||||||
// the pixels written to it *after* blending, which means
|
// the pixels written to it *after* blending, which means
|
||||||
// we get linear alpha blending rather than gamma-incorrect
|
// we get linear alpha blending rather than gamma-incorrect
|
||||||
// blending.
|
// blending.
|
||||||
if (self.config.blending == .linear)
|
if (self.config.blending.isLinear())
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm_srgb)
|
||||||
else
|
else
|
||||||
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
@intFromEnum(mtl.MTLPixelFormat.bgra8unorm),
|
||||||
|
Reference in New Issue
Block a user