config: add remaining font modifiers

This commit is contained in:
Mitchell Hashimoto
2023-10-04 22:08:19 -07:00
parent 16cfb14200
commit b98cc3d79f
6 changed files with 26 additions and 4 deletions

View File

@@ -26,6 +26,18 @@ pub fn apply(self: *Metrics, mods: ModifierSet) void {
var it = mods.iterator();
while (it.next()) |entry| {
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| {
@field(self, @tagName(tag)) = entry.value_ptr.apply(@field(self, @tagName(tag)));
},

View File

@@ -171,8 +171,9 @@ const Draw = struct {
// wave. This constant is arbitrary, change it for aesthetics.
const pos = pos: {
const MIN_HEIGHT = 7;
const height = y_max - self.pos;
break :pos if (height < MIN_HEIGHT) self.pos -| MIN_HEIGHT else self.pos;
const clamped_pos = @min(y_max, 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