mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
font: fix nerd font codegen to handle ypadding properly
Previously `ypadding` was effectively ignored, since it's mutually exclusive with `overlap`. This had a noticeable effect on the heavy bracket characters U+276C...U+2771, which were much taller than they should have been. I also fixed the vertical overlap limit, since negative `overlap` values are used in the nerd font attributes to create padding on all sides of the cell, so we don't want to limit the magnitude of the overlap for vertical padding, we only want to limit it if the value is positive. That change fixed the vertical padding for a handful of ranges, which should give more consistent results.
This commit is contained in:
@ -28,8 +28,8 @@ pub fn getConstraint(cp: u21) Constraint {
|
|||||||
.align_vertical = .center,
|
.align_vertical = .center,
|
||||||
.pad_left = 0.1,
|
.pad_left = 0.1,
|
||||||
.pad_right = 0.1,
|
.pad_right = 0.1,
|
||||||
.pad_top = 0.01,
|
.pad_top = 0.1,
|
||||||
.pad_bottom = 0.01,
|
.pad_bottom = 0.1,
|
||||||
},
|
},
|
||||||
0x276c...0x2771,
|
0x276c...0x2771,
|
||||||
=> .{
|
=> .{
|
||||||
@ -37,6 +37,8 @@ pub fn getConstraint(cp: u21) Constraint {
|
|||||||
.size_vertical = .fit,
|
.size_vertical = .fit,
|
||||||
.align_horizontal = .center,
|
.align_horizontal = .center,
|
||||||
.align_vertical = .center,
|
.align_vertical = .center,
|
||||||
|
.pad_top = 0.3,
|
||||||
|
.pad_bottom = 0.3,
|
||||||
},
|
},
|
||||||
0xe0b0,
|
0xe0b0,
|
||||||
=> .{
|
=> .{
|
||||||
@ -204,8 +206,8 @@ pub fn getConstraint(cp: u21) Constraint {
|
|||||||
.align_vertical = .center,
|
.align_vertical = .center,
|
||||||
.pad_left = 0.03,
|
.pad_left = 0.03,
|
||||||
.pad_right = 0.03,
|
.pad_right = 0.03,
|
||||||
.pad_top = 0.01,
|
.pad_top = 0.03,
|
||||||
.pad_bottom = 0.01,
|
.pad_bottom = 0.03,
|
||||||
.max_xy_ratio = 0.86,
|
.max_xy_ratio = 0.86,
|
||||||
},
|
},
|
||||||
0xe0c5,
|
0xe0c5,
|
||||||
@ -216,8 +218,8 @@ pub fn getConstraint(cp: u21) Constraint {
|
|||||||
.align_vertical = .center,
|
.align_vertical = .center,
|
||||||
.pad_left = 0.03,
|
.pad_left = 0.03,
|
||||||
.pad_right = 0.03,
|
.pad_right = 0.03,
|
||||||
.pad_top = 0.01,
|
.pad_top = 0.03,
|
||||||
.pad_bottom = 0.01,
|
.pad_bottom = 0.03,
|
||||||
.max_xy_ratio = 0.86,
|
.max_xy_ratio = 0.86,
|
||||||
},
|
},
|
||||||
0xe0c6,
|
0xe0c6,
|
||||||
@ -228,8 +230,8 @@ pub fn getConstraint(cp: u21) Constraint {
|
|||||||
.align_vertical = .center,
|
.align_vertical = .center,
|
||||||
.pad_left = 0.03,
|
.pad_left = 0.03,
|
||||||
.pad_right = 0.03,
|
.pad_right = 0.03,
|
||||||
.pad_top = 0.01,
|
.pad_top = 0.03,
|
||||||
.pad_bottom = 0.01,
|
.pad_bottom = 0.03,
|
||||||
.max_xy_ratio = 0.78,
|
.max_xy_ratio = 0.78,
|
||||||
},
|
},
|
||||||
0xe0c7,
|
0xe0c7,
|
||||||
@ -240,8 +242,8 @@ pub fn getConstraint(cp: u21) Constraint {
|
|||||||
.align_vertical = .center,
|
.align_vertical = .center,
|
||||||
.pad_left = 0.03,
|
.pad_left = 0.03,
|
||||||
.pad_right = 0.03,
|
.pad_right = 0.03,
|
||||||
.pad_top = 0.01,
|
.pad_top = 0.03,
|
||||||
.pad_bottom = 0.01,
|
.pad_bottom = 0.03,
|
||||||
.max_xy_ratio = 0.78,
|
.max_xy_ratio = 0.78,
|
||||||
},
|
},
|
||||||
0xe0cc,
|
0xe0cc,
|
||||||
|
@ -6,6 +6,8 @@ attributes and scaling rules.
|
|||||||
|
|
||||||
This does include an `eval` call! This is spooky, but we trust the nerd fonts code to
|
This does include an `eval` call! This is spooky, but we trust the nerd fonts code to
|
||||||
be safe and not malicious or anything.
|
be safe and not malicious or anything.
|
||||||
|
|
||||||
|
This script requires Python 3.12 or greater.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
@ -193,13 +195,20 @@ def emit_zig_entry_multikey(codepoints: list[int], attr: PatchSetAttributeEntry)
|
|||||||
if valign is not None:
|
if valign is not None:
|
||||||
s += f" .align_vertical = {valign},\n"
|
s += f" .align_vertical = {valign},\n"
|
||||||
|
|
||||||
|
# `overlap` and `ypadding` are mutually exclusive,
|
||||||
|
# this is asserted in the nerd fonts patcher itself.
|
||||||
if overlap:
|
if overlap:
|
||||||
pad = -overlap
|
pad = -overlap
|
||||||
s += f" .pad_left = {pad},\n"
|
s += f" .pad_left = {pad},\n"
|
||||||
s += f" .pad_right = {pad},\n"
|
s += f" .pad_right = {pad},\n"
|
||||||
v_pad = y_padding - math.copysign(min(0.01, abs(overlap)), overlap)
|
# In the nerd fonts patcher, overlap values
|
||||||
|
# are capped at 0.01 in the vertical direction.
|
||||||
|
v_pad = -min(0.01, overlap)
|
||||||
s += f" .pad_top = {v_pad},\n"
|
s += f" .pad_top = {v_pad},\n"
|
||||||
s += f" .pad_bottom = {v_pad},\n"
|
s += f" .pad_bottom = {v_pad},\n"
|
||||||
|
elif y_padding:
|
||||||
|
s += f" .pad_top = {y_padding},\n"
|
||||||
|
s += f" .pad_bottom = {y_padding},\n"
|
||||||
|
|
||||||
if xy_ratio > 0:
|
if xy_ratio > 0:
|
||||||
s += f" .max_xy_ratio = {xy_ratio},\n"
|
s += f" .max_xy_ratio = {xy_ratio},\n"
|
||||||
|
Reference in New Issue
Block a user