font: constrain dingbats

This was a regression, we were giving dingbats an extra cell of
constraint width but not actually applying constraints to them.
This commit is contained in:
Qwerasd
2025-09-03 18:01:40 -06:00
parent c3e7857a2c
commit 2464728851
3 changed files with 12 additions and 5 deletions

View File

@@ -7,7 +7,7 @@
const Constraint = @import("face.zig").RenderOptions.Constraint;
/// Get the a constraints for the provided codepoint.
pub fn getConstraint(cp: u21) Constraint {
pub fn getConstraint(cp: u21) ?Constraint {
return switch (cp) {
0x2500...0x259f,
=> .{
@@ -1060,6 +1060,6 @@ pub fn getConstraint(cp: u21) Constraint {
.align_vertical = .center,
.group_width = 1.3001222493887530,
},
else => .none,
else => null,
};
}

View File

@@ -351,8 +351,8 @@ if __name__ == "__main__":
const Constraint = @import("face.zig").RenderOptions.Constraint;
/// Get the a constraints for the provided codepoint.
pub fn getConstraint(cp: u21) Constraint {
pub fn getConstraint(cp: u21) ?Constraint {
return switch (cp) {
""")
f.write(generate_zig_switch_arms(patch_set, nerd_font))
f.write("\n else => .none,\n };\n}\n")
f.write("\n else => null,\n };\n}\n")

View File

@@ -3066,7 +3066,14 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
.thicken = self.config.font_thicken,
.thicken_strength = self.config.font_thicken_strength,
.cell_width = cell.gridWidth(),
.constraint = getConstraint(cp),
// If there's no Nerd Font constraint for this codepoint
// then, if it's a symbol, we constrain it to fit inside
// its cell(s), we don't modify the alignment at all.
.constraint = getConstraint(cp) orelse
if (cellpkg.isSymbol(cp)) .{
.size_horizontal = .fit,
.size_vertical = .fit,
} else .none,
.constraint_width = constraintWidth(cell_pin),
},
);