Skip to content

Commit

Permalink
Add new font adjust configs (#2962)
Browse files Browse the repository at this point in the history
Add keys for adjusting overline position/thickness and box drawing
thickness, + docs to each adjust key clarifying what the metric they
adjust does.
  • Loading branch information
mitchellh authored Dec 15, 2024
2 parents 71547c0 + 60b554c commit f50e8a5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/build/zsh_completions.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const zsh_completions = comptimeGenerateZshCompletions();

fn comptimeGenerateZshCompletions() []const u8 {
comptime {
@setEvalBranchQuota(19000);
@setEvalBranchQuota(50000);
var counter = std.io.countingWriter(std.io.null_writer);
try writeZshCompletions(&counter.writer());

Expand Down
16 changes: 16 additions & 0 deletions src/config/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,28 @@ const c = @cImport({
/// that things like status lines continue to look aligned.
@"adjust-cell-width": ?MetricModifier = null,
@"adjust-cell-height": ?MetricModifier = null,
/// Distance in pixels from the bottom of the cell to the text baseline.
/// Increase to move baseline UP, decrease to move baseline DOWN.
@"adjust-font-baseline": ?MetricModifier = null,
/// Distance in pixels from the top of the cell to the top of the underline.
/// Increase to move underline DOWN, decrease to move underline UP.
@"adjust-underline-position": ?MetricModifier = null,
/// Thickness in pixels of the underline.
@"adjust-underline-thickness": ?MetricModifier = null,
/// Distance in pixels from the top of the cell to the top of the strikethrough.
/// Increase to move strikethrough DOWN, decrease to move underline UP.
@"adjust-strikethrough-position": ?MetricModifier = null,
/// Thickness in pixels of the strikethrough.
@"adjust-strikethrough-thickness": ?MetricModifier = null,
/// Distance in pixels from the top of the cell to the top of the overline.
/// Increase to move overline DOWN, decrease to move underline UP.
@"adjust-overline-position": ?MetricModifier = null,
/// Thickness in pixels of the overline.
@"adjust-overline-thickness": ?MetricModifier = null,
/// Thickness in pixels of the bar cursor and outlined rect cursor.
@"adjust-cursor-thickness": ?MetricModifier = null,
/// Thickness in pixels of box drawing characters.
@"adjust-box-thickness": ?MetricModifier = null,

/// The method to use for calculating the cell width of a grapheme cluster.
/// The default value is `unicode` which uses the Unicode standard to determine
Expand Down
9 changes: 9 additions & 0 deletions src/font/SharedGridSet.zig
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ pub const DerivedConfig = struct {
@"adjust-underline-thickness": ?Metrics.Modifier,
@"adjust-strikethrough-position": ?Metrics.Modifier,
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
@"adjust-overline-position": ?Metrics.Modifier,
@"adjust-overline-thickness": ?Metrics.Modifier,
@"adjust-cursor-thickness": ?Metrics.Modifier,
@"adjust-box-thickness": ?Metrics.Modifier,
@"freetype-load-flags": font.face.FreetypeLoadFlags,

/// Initialize a DerivedConfig. The config should be either a
Expand Down Expand Up @@ -462,7 +465,10 @@ pub const DerivedConfig = struct {
.@"adjust-underline-thickness" = config.@"adjust-underline-thickness",
.@"adjust-strikethrough-position" = config.@"adjust-strikethrough-position",
.@"adjust-strikethrough-thickness" = config.@"adjust-strikethrough-thickness",
.@"adjust-overline-position" = config.@"adjust-overline-position",
.@"adjust-overline-thickness" = config.@"adjust-overline-thickness",
.@"adjust-cursor-thickness" = config.@"adjust-cursor-thickness",
.@"adjust-box-thickness" = config.@"adjust-box-thickness",
.@"freetype-load-flags" = if (font.face.FreetypeLoadFlags != void) config.@"freetype-load-flags" else {},

// This must be last so the arena contains all our allocations
Expand Down Expand Up @@ -604,7 +610,10 @@ pub const Key = struct {
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);
if (config.@"adjust-overline-position") |m| try set.put(alloc, .overline_position, m);
if (config.@"adjust-overline-thickness") |m| try set.put(alloc, .overline_thickness, m);
if (config.@"adjust-cursor-thickness") |m| try set.put(alloc, .cursor_thickness, m);
if (config.@"adjust-box-thickness") |m| try set.put(alloc, .box_thickness, m);
break :set set;
};

Expand Down

0 comments on commit f50e8a5

Please sign in to comment.