mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
font/coretext: do not assume capacity on arraylist append
Now that we're padding the cells with blanks if we have shaped ligatures we don't actually know the exact count based on the CoreText APIs, so we should just dynamically add.
This commit is contained in:
@ -322,11 +322,6 @@ pub const Shaper = struct {
|
|||||||
advances,
|
advances,
|
||||||
indices,
|
indices,
|
||||||
) |glyph, advance, index| {
|
) |glyph, advance, index| {
|
||||||
try self.cell_buf.ensureUnusedCapacity(
|
|
||||||
self.alloc,
|
|
||||||
glyphs.len,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Our cluster is also our cell X position. If the cluster changes
|
// Our cluster is also our cell X position. If the cluster changes
|
||||||
// then we need to reset our current cell offsets.
|
// then we need to reset our current cell offsets.
|
||||||
const cluster = state.codepoints.items[index].cluster;
|
const cluster = state.codepoints.items[index].cluster;
|
||||||
@ -341,7 +336,7 @@ pub const Shaper = struct {
|
|||||||
// If we have a gap between clusters then we need to
|
// If we have a gap between clusters then we need to
|
||||||
// add empty cells to the buffer.
|
// add empty cells to the buffer.
|
||||||
for (cell_offset.cluster + 1..cluster) |x| {
|
for (cell_offset.cluster + 1..cluster) |x| {
|
||||||
self.cell_buf.appendAssumeCapacity(.{
|
try self.cell_buf.append(self.alloc, .{
|
||||||
.x = @intCast(x),
|
.x = @intCast(x),
|
||||||
.glyph_index = null,
|
.glyph_index = null,
|
||||||
});
|
});
|
||||||
@ -350,7 +345,7 @@ pub const Shaper = struct {
|
|||||||
cell_offset = .{ .cluster = cluster };
|
cell_offset = .{ .cluster = cluster };
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cell_buf.appendAssumeCapacity(.{
|
try self.cell_buf.append(self.alloc, .{
|
||||||
.x = @intCast(cluster),
|
.x = @intCast(cluster),
|
||||||
.x_offset = @intFromFloat(@round(cell_offset.x)),
|
.x_offset = @intFromFloat(@round(cell_offset.x)),
|
||||||
.y_offset = @intFromFloat(@round(cell_offset.y)),
|
.y_offset = @intFromFloat(@round(cell_offset.y)),
|
||||||
@ -376,7 +371,7 @@ pub const Shaper = struct {
|
|||||||
// We need to go back to the last matched cluster and add
|
// We need to go back to the last matched cluster and add
|
||||||
// padding up to there.
|
// padding up to there.
|
||||||
for (last_cell.x + 1..last_cp.cluster + 1) |x| {
|
for (last_cell.x + 1..last_cp.cluster + 1) |x| {
|
||||||
self.cell_buf.appendAssumeCapacity(.{
|
try self.cell_buf.append(self.alloc, .{
|
||||||
.x = @intCast(x),
|
.x = @intCast(x),
|
||||||
.glyph_index = null,
|
.glyph_index = null,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user