mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-18 21:40:29 +00:00
refactor(font): move ownership of Metrics to Collection
This sets the stage for dynamically adjusting the sizes of fallback fonts based on the primary font's face metrics. It also removes a lot of unnecessary work when loading fallback fonts, since we only actually use the metrics based on the parimary font.
This commit is contained in:
@@ -111,15 +111,10 @@ pub fn deinit(self: *SharedGrid, alloc: Allocator) void {
|
||||
}
|
||||
|
||||
fn reloadMetrics(self: *SharedGrid) !void {
|
||||
// Get our cell metrics based on a regular font ascii 'M'. Why 'M'?
|
||||
// Doesn't matter, any normal ASCII will do we're just trying to make
|
||||
// sure we use the regular font.
|
||||
// We don't go through our caching layer because we want to minimize
|
||||
// possible failures.
|
||||
const collection = &self.resolver.collection;
|
||||
const index = collection.getIndex('M', .regular, .{ .any = {} }).?;
|
||||
const face = try collection.getFace(index);
|
||||
self.metrics = face.metrics;
|
||||
try collection.updateMetrics();
|
||||
|
||||
self.metrics = collection.metrics.?;
|
||||
|
||||
// Setup our sprite font.
|
||||
self.resolver.sprite = .{ .metrics = self.metrics };
|
||||
|
||||
Reference in New Issue
Block a user