mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00

* update zig * pkg/fontconfig: clean up @as * pkg/freetype,harfbuzz: clean up @as * pkg/imgui: clean up @as * pkg/macos: clean up @as * pkg/pixman,utf8proc: clean up @as * clean up @as * lots more @as cleanup * undo flatpak changes * clean up @as
32 lines
886 B
Zig
32 lines
886 B
Zig
const std = @import("std");
|
|
const c = @import("c.zig");
|
|
const imgui = @import("main.zig");
|
|
const Allocator = std.mem.Allocator;
|
|
|
|
pub const FontAtlas = opaque {
|
|
pub fn addFontFromMemoryTTF(
|
|
self: *FontAtlas,
|
|
data: []const u8,
|
|
size_px: f32,
|
|
) void {
|
|
// We never want the data to be copied by the Atlas, its not
|
|
// very Zig-like, so we just always set this to false.
|
|
var cfg = c.ImFontConfig_ImFontConfig();
|
|
cfg.*.FontDataOwnedByAtlas = false;
|
|
defer c.ImFontConfig_destroy(cfg);
|
|
|
|
_ = c.ImFontAtlas_AddFontFromMemoryTTF(
|
|
self.cval(),
|
|
@ptrFromInt(@intFromPtr(data.ptr)),
|
|
@intCast(data.len),
|
|
size_px,
|
|
cfg,
|
|
null,
|
|
);
|
|
}
|
|
|
|
pub inline fn cval(self: *FontAtlas) *c.ImFontAtlas {
|
|
return @ptrCast(@alignCast(self));
|
|
}
|
|
};
|