mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
build: generate nerd font attributes during the build
Rather than committing a generated Zig file, build it on the fly during the build.
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
pkg-config,
|
pkg-config,
|
||||||
zig_0_14,
|
zig_0_14,
|
||||||
pandoc,
|
pandoc,
|
||||||
|
python3,
|
||||||
revision ? "dirty",
|
revision ? "dirty",
|
||||||
optimize ? "Debug",
|
optimize ? "Debug",
|
||||||
enableX11 ? true,
|
enableX11 ? true,
|
||||||
@ -79,6 +80,7 @@ in
|
|||||||
blueprint-compiler
|
blueprint-compiler
|
||||||
libxml2 # for xmllint
|
libxml2 # for xmllint
|
||||||
gettext
|
gettext
|
||||||
|
python3 # for generating nerd font attributes
|
||||||
]
|
]
|
||||||
++ lib.optionals enableWayland [
|
++ lib.optionals enableWayland [
|
||||||
wayland-scanner
|
wayland-scanner
|
||||||
|
@ -502,6 +502,20 @@ pub fn add(
|
|||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
{
|
{
|
||||||
|
const generate_nerd_font_attributes = b.addSystemCommand(&.{
|
||||||
|
"python",
|
||||||
|
});
|
||||||
|
generate_nerd_font_attributes.addFileArg(b.path("src/font/nerd_font_codegen.py"));
|
||||||
|
generate_nerd_font_attributes.setStdIn(.{ .lazy_path = b.path("vendor/nerd-fonts/font-patcher.py") });
|
||||||
|
const nerd_font_attributes_source = generate_nerd_font_attributes.captureStdOut();
|
||||||
|
const nerd_font_attributes_module = b.addModule("nerd-font-attributes", .{
|
||||||
|
.root_source_file = nerd_font_attributes_source,
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
step.root_module.addImport("nerd-font-attributes", nerd_font_attributes_module);
|
||||||
|
|
||||||
// JetBrains Mono
|
// JetBrains Mono
|
||||||
const jb_mono = b.dependency("jetbrains_mono", .{});
|
const jb_mono = b.dependency("jetbrains_mono", .{});
|
||||||
step.root_module.addAnonymousImport(
|
step.root_module.addAnonymousImport(
|
||||||
|
@ -1,349 +0,0 @@
|
|||||||
//! This is a generated file, produced by nerd_font_codegen.py
|
|
||||||
//! DO NOT EDIT BY HAND!
|
|
||||||
//!
|
|
||||||
//! This file provides info extracted from the nerd fonts patcher script,
|
|
||||||
//! specifying the scaling/positioning attributes of various glyphs.
|
|
||||||
|
|
||||||
const Constraint = @import("face.zig").RenderOptions.Constraint;
|
|
||||||
|
|
||||||
/// Get the a constraints for the provided codepoint.
|
|
||||||
pub fn getConstraint(cp: u21) Constraint {
|
|
||||||
return switch (cp) {
|
|
||||||
0x2500...0x259f,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .center,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.02,
|
|
||||||
.pad_right = -0.02,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
},
|
|
||||||
0x2630,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .cover,
|
|
||||||
.size_vertical = .fit,
|
|
||||||
.align_horizontal = .center,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = 0.1,
|
|
||||||
.pad_right = 0.1,
|
|
||||||
.pad_top = 0.01,
|
|
||||||
.pad_bottom = 0.01,
|
|
||||||
},
|
|
||||||
0x276c...0x2771,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .cover,
|
|
||||||
.size_vertical = .fit,
|
|
||||||
.align_horizontal = .center,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0b0,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.06,
|
|
||||||
.pad_right = -0.06,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0b1,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0b2,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.06,
|
|
||||||
.pad_right = -0.06,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0b3,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0b4,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.06,
|
|
||||||
.pad_right = -0.06,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.59,
|
|
||||||
},
|
|
||||||
0xe0b5,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.max_xy_ratio = 0.5,
|
|
||||||
},
|
|
||||||
0xe0b6,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.06,
|
|
||||||
.pad_right = -0.06,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.59,
|
|
||||||
},
|
|
||||||
0xe0b7,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.max_xy_ratio = 0.5,
|
|
||||||
},
|
|
||||||
0xe0b8,
|
|
||||||
0xe0bc,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.05,
|
|
||||||
.pad_right = -0.05,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
},
|
|
||||||
0xe0b9,
|
|
||||||
0xe0bd,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0ba,
|
|
||||||
0xe0be,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.05,
|
|
||||||
.pad_right = -0.05,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
},
|
|
||||||
0xe0bb,
|
|
||||||
0xe0bf,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0c0,
|
|
||||||
0xe0c8,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.05,
|
|
||||||
.pad_right = -0.05,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
},
|
|
||||||
0xe0c1,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0c2,
|
|
||||||
0xe0ca,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.05,
|
|
||||||
.pad_right = -0.05,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
},
|
|
||||||
0xe0c3,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0c4,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = 0.03,
|
|
||||||
.pad_right = 0.03,
|
|
||||||
.pad_top = 0.01,
|
|
||||||
.pad_bottom = 0.01,
|
|
||||||
.max_xy_ratio = 0.86,
|
|
||||||
},
|
|
||||||
0xe0c5,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = 0.03,
|
|
||||||
.pad_right = 0.03,
|
|
||||||
.pad_top = 0.01,
|
|
||||||
.pad_bottom = 0.01,
|
|
||||||
.max_xy_ratio = 0.86,
|
|
||||||
},
|
|
||||||
0xe0c6,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = 0.03,
|
|
||||||
.pad_right = 0.03,
|
|
||||||
.pad_top = 0.01,
|
|
||||||
.pad_bottom = 0.01,
|
|
||||||
.max_xy_ratio = 0.78,
|
|
||||||
},
|
|
||||||
0xe0c7,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = 0.03,
|
|
||||||
.pad_right = 0.03,
|
|
||||||
.pad_top = 0.01,
|
|
||||||
.pad_bottom = 0.01,
|
|
||||||
.max_xy_ratio = 0.78,
|
|
||||||
},
|
|
||||||
0xe0cc,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.02,
|
|
||||||
.pad_right = -0.02,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.85,
|
|
||||||
},
|
|
||||||
0xe0cd,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.max_xy_ratio = 0.865,
|
|
||||||
},
|
|
||||||
0xe0ce,
|
|
||||||
0xe0d0...0xe0d1,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .cover,
|
|
||||||
.size_vertical = .cover,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0cf,
|
|
||||||
0xe0d3,
|
|
||||||
0xe0d5,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .cover,
|
|
||||||
.size_vertical = .cover,
|
|
||||||
.align_horizontal = .center,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
0xe0d2,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.02,
|
|
||||||
.pad_right = -0.02,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0d4,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.02,
|
|
||||||
.pad_right = -0.02,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0d6,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .start,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.05,
|
|
||||||
.pad_right = -0.05,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0xe0d7,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .stretch,
|
|
||||||
.size_vertical = .stretch,
|
|
||||||
.align_horizontal = .end,
|
|
||||||
.align_vertical = .center,
|
|
||||||
.pad_left = -0.05,
|
|
||||||
.pad_right = -0.05,
|
|
||||||
.pad_top = -0.01,
|
|
||||||
.pad_bottom = -0.01,
|
|
||||||
.max_xy_ratio = 0.7,
|
|
||||||
},
|
|
||||||
0x23fb...0x23fe,
|
|
||||||
0x2665,
|
|
||||||
0x26a1,
|
|
||||||
0x2b58,
|
|
||||||
0xe000...0xe0a9,
|
|
||||||
0xe4fa...0xe7ef,
|
|
||||||
0xea60...0xec1e,
|
|
||||||
0xed00...0xf847,
|
|
||||||
0xf0001...0xf1af0,
|
|
||||||
=> .{
|
|
||||||
.size_horizontal = .fit,
|
|
||||||
.size_vertical = .fit,
|
|
||||||
.align_horizontal = .center,
|
|
||||||
.align_vertical = .center,
|
|
||||||
},
|
|
||||||
else => .none,
|
|
||||||
};
|
|
||||||
}
|
|
@ -244,10 +244,8 @@ if __name__ == "__main__":
|
|||||||
//! This file provides info extracted from the nerd fonts patcher script,
|
//! This file provides info extracted from the nerd fonts patcher script,
|
||||||
//! specifying the scaling/positioning attributes of various glyphs.
|
//! specifying the scaling/positioning attributes of various glyphs.
|
||||||
|
|
||||||
const Constraint = @import("face.zig").RenderOptions.Constraint;
|
|
||||||
|
|
||||||
/// Get the a constraints for the provided codepoint.
|
/// Get the a constraints for the provided codepoint.
|
||||||
pub fn getConstraint(cp: u21) Constraint {
|
pub fn getConstraint(comptime T: type, cp: u21) T {
|
||||||
return switch (cp) {""")
|
return switch (cp) {""")
|
||||||
print(generate_zig_switch_arms(patch_set))
|
print(generate_zig_switch_arms(patch_set))
|
||||||
print(" else => .none,\n };\n}")
|
print(" else => .none,\n };\n}")
|
||||||
|
@ -25,8 +25,9 @@ const Allocator = std.mem.Allocator;
|
|||||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||||
const Terminal = terminal.Terminal;
|
const Terminal = terminal.Terminal;
|
||||||
const Health = renderer.Health;
|
const Health = renderer.Health;
|
||||||
|
const Constraint = @import("../font/face.zig").RenderOptions.Constraint;
|
||||||
|
|
||||||
const getConstraint = @import("../font/nerd_font_attributes.zig").getConstraint;
|
const getConstraint = @import("nerd-font-attributes").getConstraint;
|
||||||
|
|
||||||
const FileType = @import("../file_type.zig").FileType;
|
const FileType = @import("../file_type.zig").FileType;
|
||||||
|
|
||||||
@ -3027,7 +3028,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
.thicken = self.config.font_thicken,
|
.thicken = self.config.font_thicken,
|
||||||
.thicken_strength = self.config.font_thicken_strength,
|
.thicken_strength = self.config.font_thicken_strength,
|
||||||
.cell_width = cell.gridWidth(),
|
.cell_width = cell.gridWidth(),
|
||||||
.constraint = getConstraint(cp),
|
.constraint = getConstraint(Constraint, cp),
|
||||||
.constraint_width = constraintWidth(cell_pin),
|
.constraint_width = constraintWidth(cell_pin),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user