mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
config: add remaining font modifiers
This commit is contained in:
@ -231,6 +231,10 @@ pub fn init(
|
|||||||
if (config.@"adjust-cell-width") |m| try set.put(alloc, .cell_width, m);
|
if (config.@"adjust-cell-width") |m| try set.put(alloc, .cell_width, m);
|
||||||
if (config.@"adjust-cell-height") |m| try set.put(alloc, .cell_height, m);
|
if (config.@"adjust-cell-height") |m| try set.put(alloc, .cell_height, m);
|
||||||
if (config.@"adjust-font-baseline") |m| try set.put(alloc, .cell_baseline, m);
|
if (config.@"adjust-font-baseline") |m| try set.put(alloc, .cell_baseline, m);
|
||||||
|
if (config.@"adjust-underline-position") |m| try set.put(alloc, .underline_position, m);
|
||||||
|
if (config.@"adjust-underline-thickness") |m| try set.put(alloc, .underline_thickness, m);
|
||||||
|
if (config.@"adjust-strikethrough-position") |m| try set.put(alloc, .strikethrough_position, m);
|
||||||
|
if (config.@"adjust-strikethrough-thickness") |m| try set.put(alloc, .strikethrough_thickness, m);
|
||||||
break :set set;
|
break :set set;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -138,6 +138,10 @@ const c = @cImport({
|
|||||||
@"adjust-cell-width": ?MetricModifier = null,
|
@"adjust-cell-width": ?MetricModifier = null,
|
||||||
@"adjust-cell-height": ?MetricModifier = null,
|
@"adjust-cell-height": ?MetricModifier = null,
|
||||||
@"adjust-font-baseline": ?MetricModifier = null,
|
@"adjust-font-baseline": ?MetricModifier = null,
|
||||||
|
@"adjust-underline-position": ?MetricModifier = null,
|
||||||
|
@"adjust-underline-thickness": ?MetricModifier = null,
|
||||||
|
@"adjust-strikethrough-position": ?MetricModifier = null,
|
||||||
|
@"adjust-strikethrough-thickness": ?MetricModifier = null,
|
||||||
|
|
||||||
/// Background color for the window.
|
/// Background color for the window.
|
||||||
background: Color = .{ .r = 0x28, .g = 0x2C, .b = 0x34 },
|
background: Color = .{ .r = 0x28, .g = 0x2C, .b = 0x34 },
|
||||||
|
@ -26,6 +26,18 @@ pub fn apply(self: *Metrics, mods: ModifierSet) void {
|
|||||||
var it = mods.iterator();
|
var it = mods.iterator();
|
||||||
while (it.next()) |entry| {
|
while (it.next()) |entry| {
|
||||||
switch (entry.key_ptr.*) {
|
switch (entry.key_ptr.*) {
|
||||||
|
// We clamp these values to a minimum of 1 to prevent divide-by-zero
|
||||||
|
// in downstream operations.
|
||||||
|
inline .cell_width,
|
||||||
|
.cell_height,
|
||||||
|
=> |tag| {
|
||||||
|
const original = @field(self, @tagName(tag));
|
||||||
|
@field(self, @tagName(tag)) = @max(
|
||||||
|
entry.value_ptr.apply(original),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
inline else => |tag| {
|
inline else => |tag| {
|
||||||
@field(self, @tagName(tag)) = entry.value_ptr.apply(@field(self, @tagName(tag)));
|
@field(self, @tagName(tag)) = entry.value_ptr.apply(@field(self, @tagName(tag)));
|
||||||
},
|
},
|
||||||
|
@ -171,8 +171,9 @@ const Draw = struct {
|
|||||||
// wave. This constant is arbitrary, change it for aesthetics.
|
// wave. This constant is arbitrary, change it for aesthetics.
|
||||||
const pos = pos: {
|
const pos = pos: {
|
||||||
const MIN_HEIGHT = 7;
|
const MIN_HEIGHT = 7;
|
||||||
const height = y_max - self.pos;
|
const clamped_pos = @min(y_max, self.pos);
|
||||||
break :pos if (height < MIN_HEIGHT) self.pos -| MIN_HEIGHT else self.pos;
|
const height = y_max - clamped_pos;
|
||||||
|
break :pos if (height < MIN_HEIGHT) clamped_pos -| MIN_HEIGHT else clamped_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The full heightof the wave can be from the bottom to the
|
// The full heightof the wave can be from the bottom to the
|
||||||
|
@ -211,7 +211,8 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
|||||||
options.font_group.group.sprite = font.sprite.Face{
|
options.font_group.group.sprite = font.sprite.Face{
|
||||||
.width = metrics.cell_width,
|
.width = metrics.cell_width,
|
||||||
.height = metrics.cell_height,
|
.height = metrics.cell_height,
|
||||||
.thickness = 2 * @as(u32, if (options.config.font_thicken) 2 else 1),
|
.thickness = metrics.underline_thickness *
|
||||||
|
@as(u32, if (options.config.font_thicken) 2 else 1),
|
||||||
.underline_position = metrics.underline_position,
|
.underline_position = metrics.underline_position,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ fn resetFontMetrics(
|
|||||||
font_group.group.sprite = font.sprite.Face{
|
font_group.group.sprite = font.sprite.Face{
|
||||||
.width = metrics.cell_width,
|
.width = metrics.cell_width,
|
||||||
.height = metrics.cell_height,
|
.height = metrics.cell_height,
|
||||||
.thickness = 2 * @as(u32, if (font_thicken) 2 else 1),
|
.thickness = metrics.underline_thickness * @as(u32, if (font_thicken) 2 else 1),
|
||||||
.underline_position = metrics.underline_position,
|
.underline_position = metrics.underline_position,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user