mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 03:16:33 +00:00
Skip patchsets and codepoints not in SymbolsNF
This commit is contained in:

committed by
Mitchell Hashimoto

parent
a1b7ea2e71
commit
d07237fff5
@@ -9,17 +9,6 @@ const Constraint = @import("face.zig").RenderOptions.Constraint;
|
||||
/// Get the constraints for the provided codepoint.
|
||||
pub fn getConstraint(cp: u21) ?Constraint {
|
||||
return switch (cp) {
|
||||
0x2500...0x259f,
|
||||
=> .{
|
||||
.size = .stretch,
|
||||
.max_constraint_width = 1,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.pad_left = -0.02,
|
||||
.pad_right = -0.02,
|
||||
.pad_top = -0.01,
|
||||
.pad_bottom = -0.01,
|
||||
},
|
||||
0x2630,
|
||||
=> .{
|
||||
.size = .cover,
|
||||
@@ -291,8 +280,6 @@ pub fn getConstraint(cp: u21) ?Constraint {
|
||||
.align_vertical = .center1,
|
||||
},
|
||||
0xe0cf,
|
||||
0xe0d3,
|
||||
0xe0d5,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.align_horizontal = .center1,
|
||||
@@ -350,22 +337,31 @@ pub fn getConstraint(cp: u21) ?Constraint {
|
||||
0x2665,
|
||||
0x26a1,
|
||||
0x2b58,
|
||||
0xe000...0xe0a9,
|
||||
0xe4fa...0xe7ef,
|
||||
0xe000...0xe00a,
|
||||
0xe0a0...0xe0a3,
|
||||
0xe5fa...0xe6b8,
|
||||
0xe700...0xe7ef,
|
||||
0xea60,
|
||||
0xea62...0xea7c,
|
||||
0xea7e...0xea98,
|
||||
0xea7e...0xea88,
|
||||
0xea8a...0xea8c,
|
||||
0xea8f...0xea98,
|
||||
0xeaa3...0xeab3,
|
||||
0xeab8...0xead3,
|
||||
0xead7...0xeb42,
|
||||
0xeb44...0xeb6d,
|
||||
0xeab8...0xeac7,
|
||||
0xeac9,
|
||||
0xeacc...0xead3,
|
||||
0xead7...0xeb09,
|
||||
0xeb0b...0xeb42,
|
||||
0xeb44...0xeb4e,
|
||||
0xeb50...0xeb6d,
|
||||
0xeb72...0xeb89,
|
||||
0xeb8b...0xeb99,
|
||||
0xeb9b...0xebd4,
|
||||
0xebd7...0xec06,
|
||||
0xec08...0xec0a,
|
||||
0xec0d...0xec1e,
|
||||
0xed00...0xf02f,
|
||||
0xed00...0xefce,
|
||||
0xf000...0xf02f,
|
||||
0xf031...0xf03c,
|
||||
0xf03f,
|
||||
0xf041...0xf043,
|
||||
@@ -384,10 +380,22 @@ pub fn getConstraint(cp: u21) ?Constraint {
|
||||
0xf0cb...0xf0d5,
|
||||
0xf0d7...0xf0dd,
|
||||
0xf0df...0xf0e6,
|
||||
0xf0e8...0xf295,
|
||||
0xf0e8...0xf105,
|
||||
0xf108...0xf12f,
|
||||
0xf131...0xf140,
|
||||
0xf142...0xf152,
|
||||
0xf155,
|
||||
0xf15a...0xf174,
|
||||
0xf176,
|
||||
0xf179...0xf181,
|
||||
0xf183...0xf220,
|
||||
0xf223,
|
||||
0xf22e...0xf254,
|
||||
0xf259,
|
||||
0xf25c...0xf295,
|
||||
0xf297...0xf2c4,
|
||||
0xf2c6...0xf2ef,
|
||||
0xf2f1...0xf847,
|
||||
0xf2f1...0xf381,
|
||||
0xf0001...0xf1af0,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
@@ -672,6 +680,8 @@ pub fn getConstraint(cp: u21) ?Constraint {
|
||||
0xf03e,
|
||||
0xf071,
|
||||
0xf08c,
|
||||
0xf153...0xf154,
|
||||
0xf158,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
@@ -828,6 +838,161 @@ pub fn getConstraint(cp: u21) ?Constraint {
|
||||
.relative_height = 0.9998803756692248,
|
||||
.relative_y = 0.0001196243307751,
|
||||
},
|
||||
0xf106...0xf107,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.5000000000000000,
|
||||
.relative_y = 0.2853688029020556,
|
||||
},
|
||||
0xf130,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.9998602571268865,
|
||||
},
|
||||
0xf141,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.2593984962406015,
|
||||
.relative_y = 0.3696741854636592,
|
||||
},
|
||||
0xf156,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.8752505446623093,
|
||||
.relative_y = 0.0623155929038282,
|
||||
},
|
||||
0xf157,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.8756468797564688,
|
||||
.relative_y = 0.0624338624338624,
|
||||
},
|
||||
0xf159,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.8756067947646895,
|
||||
.relative_y = 0.0623492063492063,
|
||||
},
|
||||
0xf175,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.9989423585404548,
|
||||
.relative_y = 0.0005288207297726,
|
||||
},
|
||||
0xf177...0xf178,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.6250661025912215,
|
||||
.relative_y = 0.1877313590692755,
|
||||
},
|
||||
0xf182,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_width = 0.9998046921689268,
|
||||
},
|
||||
0xf221,
|
||||
0xf224...0xf226,
|
||||
0xf228,
|
||||
0xf22a,
|
||||
0xf22c,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.9994854643684076,
|
||||
},
|
||||
0xf222,
|
||||
0xf227,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.8746819883943630,
|
||||
.relative_y = 0.0624017379870223,
|
||||
},
|
||||
0xf229,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.9370837263813853,
|
||||
.relative_y = 0.0624017379870223,
|
||||
},
|
||||
0xf22b,
|
||||
0xf22d,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.6874767744332962,
|
||||
.relative_y = 0.1560043449675557,
|
||||
},
|
||||
0xf255...0xf256,
|
||||
0xf25a,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.9993997599039616,
|
||||
},
|
||||
0xf257,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.7810124049619848,
|
||||
.relative_y = 0.0935945806894186,
|
||||
},
|
||||
0xf258,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.7498142113988452,
|
||||
.relative_y = 0.1247927742525582,
|
||||
},
|
||||
0xf25b,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
.height = .icon,
|
||||
.align_horizontal = .center1,
|
||||
.align_vertical = .center1,
|
||||
.relative_height = 0.9975006099019084,
|
||||
},
|
||||
0xf296,
|
||||
=> .{
|
||||
.size = .fit_cover1,
|
||||
|
@@ -57,6 +57,7 @@ class PatchSetAttributeEntry(TypedDict):
|
||||
|
||||
|
||||
class PatchSet(TypedDict):
|
||||
Name: str
|
||||
SymStart: int
|
||||
SymEnd: int
|
||||
SrcStart: int | None
|
||||
@@ -113,20 +114,43 @@ class PatchSetExtractor(ast.NodeVisitor):
|
||||
if hasattr(ast, "unparse"):
|
||||
return eval(
|
||||
ast.unparse(node),
|
||||
{"box_keep": True},
|
||||
{"self": SimpleNamespace(args=SimpleNamespace(careful=True))},
|
||||
{"box_enabled": False, "box_keep": False},
|
||||
{
|
||||
"self": SimpleNamespace(
|
||||
args=SimpleNamespace(
|
||||
careful=False,
|
||||
custom=False,
|
||||
fontawesome=True,
|
||||
fontawesomeextension=True,
|
||||
fontlogos=True,
|
||||
octicons=True,
|
||||
codicons=True,
|
||||
powersymbols=True,
|
||||
pomicons=True,
|
||||
powerline=True,
|
||||
powerlineextra=True,
|
||||
material=True,
|
||||
weather=True,
|
||||
)
|
||||
),
|
||||
},
|
||||
)
|
||||
msg = f"<cannot eval: {type(node).__name__}>"
|
||||
raise ValueError(msg) from None
|
||||
|
||||
def process_patch_entry(self, dict_node: ast.Dict) -> None:
|
||||
entry = {}
|
||||
disallowed_key_nodes = frozenset({"Enabled", "Name", "Filename", "Exact"})
|
||||
disallowed_key_nodes = frozenset({"Filename", "Exact"})
|
||||
for key_node, value_node in zip(dict_node.keys, dict_node.values):
|
||||
if (
|
||||
isinstance(key_node, ast.Constant)
|
||||
and key_node.value not in disallowed_key_nodes
|
||||
):
|
||||
if key_node.value == "Enabled":
|
||||
if self.safe_literal_eval(value_node):
|
||||
continue # This patch set is enabled, continue to next key
|
||||
else:
|
||||
return # This patch set is disabled, skip
|
||||
key = ast.literal_eval(cast("ast.Constant", key_node))
|
||||
entry[key] = self.resolve_symbol(value_node)
|
||||
self.patch_set_values.append(cast("PatchSet", entry))
|
||||
@@ -275,12 +299,17 @@ def generate_zig_switch_arms(
|
||||
|
||||
entries: dict[int, PatchSetAttributeEntry] = {}
|
||||
for entry in patch_sets:
|
||||
print(f"Info: Extracting rules from patch set '{entry['Name']}'")
|
||||
attributes = entry["Attributes"]
|
||||
|
||||
for cp in range(entry["SymStart"], entry["SymEnd"] + 1):
|
||||
entries[cp] = attributes["default"].copy()
|
||||
|
||||
entries |= {k: v for k, v in attributes.items() if isinstance(k, int)}
|
||||
if cp not in cmap:
|
||||
print(f"Info: Skipping missing codepoint {hex(cp)}")
|
||||
continue
|
||||
if cp in attributes:
|
||||
entries[cp] = attributes[cp].copy()
|
||||
else:
|
||||
entries[cp] = attributes["default"].copy()
|
||||
|
||||
if entry["ScaleRules"] is not None:
|
||||
if "ScaleGroups" not in entry["ScaleRules"]:
|
||||
@@ -335,8 +364,6 @@ def generate_zig_switch_arms(
|
||||
this_bounds[0] - xMin
|
||||
) / group_width
|
||||
|
||||
del entries[0]
|
||||
|
||||
# Group codepoints by attribute key
|
||||
grouped = defaultdict[AttributeHash, list[int]](list)
|
||||
for cp, attr in entries.items():
|
||||
|
Reference in New Issue
Block a user