mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
enable freetype with imgui
This commit is contained in:
16
build.zig
16
build.zig
@ -219,12 +219,12 @@ fn addDeps(
|
|||||||
const glfw_opts: glfw.Options = .{ .metal = false, .opengl = false };
|
const glfw_opts: glfw.Options = .{ .metal = false, .opengl = false };
|
||||||
try glfw.link(b, step, glfw_opts);
|
try glfw.link(b, step, glfw_opts);
|
||||||
|
|
||||||
// Imgui
|
// Imgui, we have to do this later since we need some information
|
||||||
const imgui_backends = [_][]const u8{ "glfw", "opengl3" };
|
const imgui_backends = [_][]const u8{ "glfw", "opengl3" };
|
||||||
const imgui_step = try imgui.link(b, step, .{
|
var imgui_opts: imgui.Options = .{
|
||||||
.backends = &imgui_backends,
|
.backends = &imgui_backends,
|
||||||
});
|
.freetype = .{ .enabled = true },
|
||||||
try glfw.link(b, imgui_step, glfw_opts);
|
};
|
||||||
|
|
||||||
// Dynamic link
|
// Dynamic link
|
||||||
if (!static) {
|
if (!static) {
|
||||||
@ -305,7 +305,15 @@ fn addDeps(
|
|||||||
});
|
});
|
||||||
libxml2_lib.link(fontconfig_step);
|
libxml2_lib.link(fontconfig_step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Imgui
|
||||||
|
imgui_opts.freetype.step = freetype_step;
|
||||||
|
imgui_opts.freetype.include = &freetype.include_paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Imgui
|
||||||
|
const imgui_step = try imgui.link(b, step, imgui_opts);
|
||||||
|
try glfw.link(b, imgui_step, glfw_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn conformanceSteps(
|
fn conformanceSteps(
|
||||||
|
@ -19,6 +19,14 @@ fn thisDir() []const u8 {
|
|||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
backends: ?[]const []const u8 = null,
|
backends: ?[]const []const u8 = null,
|
||||||
|
|
||||||
|
freetype: Freetype = .{},
|
||||||
|
|
||||||
|
pub const Freetype = struct {
|
||||||
|
enabled: bool = false,
|
||||||
|
step: ?*std.build.LibExeObjStep = null,
|
||||||
|
include: ?[]const []const u8 = null,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn link(
|
pub fn link(
|
||||||
@ -54,6 +62,10 @@ pub fn buildImgui(
|
|||||||
try flags.appendSlice(&.{
|
try flags.appendSlice(&.{
|
||||||
"-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1",
|
"-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1",
|
||||||
|
|
||||||
|
// We want to always have STB in addition to Freetype to
|
||||||
|
// fix compilation issues with cimgui.
|
||||||
|
"-DIMGUI_ENABLE_STB_TRUETYPE=1",
|
||||||
|
|
||||||
//"-fno-sanitize=undefined",
|
//"-fno-sanitize=undefined",
|
||||||
});
|
});
|
||||||
switch (target.getOsTag()) {
|
switch (target.getOsTag()) {
|
||||||
@ -65,6 +77,26 @@ pub fn buildImgui(
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Freetype
|
||||||
|
if (opt.freetype.enabled) {
|
||||||
|
if (opt.freetype.step) |freetype|
|
||||||
|
lib.linkLibrary(freetype)
|
||||||
|
else
|
||||||
|
lib.linkSystemLibrary("freetype2");
|
||||||
|
|
||||||
|
if (opt.freetype.include) |dirs|
|
||||||
|
for (dirs) |dir| lib.addIncludePath(dir);
|
||||||
|
|
||||||
|
// Enable in defines
|
||||||
|
try flags.appendSlice(&.{
|
||||||
|
"-DIMGUI_ENABLE_FREETYPE=1",
|
||||||
|
"-DCIMGUI_FREETYPE=1",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add necessary C file
|
||||||
|
lib.addCSourceFile(root ++ "imgui/misc/freetype/imgui_freetype.cpp", flags.items);
|
||||||
|
}
|
||||||
|
|
||||||
// C files
|
// C files
|
||||||
lib.addCSourceFiles(srcs, flags.items);
|
lib.addCSourceFiles(srcs, flags.items);
|
||||||
if (opt.backends) |backends| {
|
if (opt.backends) |backends| {
|
||||||
|
Reference in New Issue
Block a user