mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
font: use explicit error sets where we can
This commit is contained in:
@ -83,7 +83,7 @@ pub const Region = extern struct {
|
||||
height: u32,
|
||||
};
|
||||
|
||||
pub fn init(alloc: Allocator, size: u32, format: Format) !Atlas {
|
||||
pub fn init(alloc: Allocator, size: u32, format: Format) Allocator.Error!Atlas {
|
||||
var result = Atlas{
|
||||
.data = try alloc.alloc(u8, size * size * format.depth()),
|
||||
.size = size,
|
||||
@ -111,7 +111,12 @@ pub fn deinit(self: *Atlas, alloc: Allocator) void {
|
||||
///
|
||||
/// May allocate to add a new rectangle into the internal list of rectangles.
|
||||
/// This will not automatically enlarge the texture if it is full.
|
||||
pub fn reserve(self: *Atlas, alloc: Allocator, width: u32, height: u32) !Region {
|
||||
pub fn reserve(
|
||||
self: *Atlas,
|
||||
alloc: Allocator,
|
||||
width: u32,
|
||||
height: u32,
|
||||
) (Allocator.Error || Error)!Region {
|
||||
// x, y are populated within :best_idx below
|
||||
var region: Region = .{ .x = 0, .y = 0, .width = width, .height = height };
|
||||
|
||||
@ -312,7 +317,7 @@ pub fn dump(self: Atlas, writer: anytype) !void {
|
||||
else => {
|
||||
log.err("Unsupported format for dump: {}", .{self.format});
|
||||
@panic("Cannot dump this atlas format.");
|
||||
}
|
||||
},
|
||||
}),
|
||||
self.size,
|
||||
self.size,
|
||||
|
@ -102,7 +102,11 @@ pub const Canvas = struct {
|
||||
}
|
||||
|
||||
/// Write the data in this drawing to the atlas.
|
||||
pub fn writeAtlas(self: *Canvas, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region {
|
||||
pub fn writeAtlas(
|
||||
self: *Canvas,
|
||||
alloc: Allocator,
|
||||
atlas: *font.Atlas,
|
||||
) (Allocator.Error || font.Atlas.Error)!font.Atlas.Region {
|
||||
assert(atlas.format == .grayscale);
|
||||
|
||||
const width = @as(u32, @intCast(self.sfc.getWidth()));
|
||||
|
Reference in New Issue
Block a user