mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 19:26:09 +03:00
Merge pull request #1715 from g-cassie/coretext-minor-fixes
coretext - minor fixes
This commit is contained in:
@ -81,7 +81,7 @@ pub const Font = opaque {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getBoundingRectForGlyphs(
|
pub fn getBoundingRectsForGlyphs(
|
||||||
self: *Font,
|
self: *Font,
|
||||||
orientation: FontOrientation,
|
orientation: FontOrientation,
|
||||||
glyphs: []const graphics.Glyph,
|
glyphs: []const graphics.Glyph,
|
||||||
@ -197,11 +197,11 @@ test {
|
|||||||
|
|
||||||
// Bounding rect
|
// Bounding rect
|
||||||
{
|
{
|
||||||
var rect = font.getBoundingRectForGlyphs(.horizontal, &glyphs, null);
|
var rect = font.getBoundingRectsForGlyphs(.horizontal, &glyphs, null);
|
||||||
try testing.expect(rect.size.width > 0);
|
try testing.expect(rect.size.width > 0);
|
||||||
|
|
||||||
var singles: [1]graphics.Rect = undefined;
|
var singles: [1]graphics.Rect = undefined;
|
||||||
rect = font.getBoundingRectForGlyphs(.horizontal, &glyphs, &singles);
|
rect = font.getBoundingRectsForGlyphs(.horizontal, &glyphs, &singles);
|
||||||
try testing.expect(rect.size.width > 0);
|
try testing.expect(rect.size.width > 0);
|
||||||
try testing.expect(singles[0].size.width > 0);
|
try testing.expect(singles[0].size.width > 0);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ pub const Face = struct {
|
|||||||
var glyphs = [_]macos.graphics.Glyph{@intCast(glyph_index)};
|
var glyphs = [_]macos.graphics.Glyph{@intCast(glyph_index)};
|
||||||
|
|
||||||
// Get the bounding rect for rendering this glyph.
|
// Get the bounding rect for rendering this glyph.
|
||||||
const rect = self.font.getBoundingRectForGlyphs(.horizontal, &glyphs, null);
|
const rect = self.font.getBoundingRectsForGlyphs(.horizontal, &glyphs, null);
|
||||||
|
|
||||||
// The x/y that we render the glyph at. The Y value has to be flipped
|
// The x/y that we render the glyph at. The Y value has to be flipped
|
||||||
// because our coordinates in 3D space are (0, 0) bottom left with
|
// because our coordinates in 3D space are (0, 0) bottom left with
|
||||||
@ -396,7 +396,6 @@ pub const Face = struct {
|
|||||||
const offset_y: i32 = offset_y: {
|
const offset_y: i32 = offset_y: {
|
||||||
// Our Y coordinate in 3D is (0, 0) bottom left, +y is UP.
|
// Our Y coordinate in 3D is (0, 0) bottom left, +y is UP.
|
||||||
// We need to calculate our baseline from the bottom of a cell.
|
// We need to calculate our baseline from the bottom of a cell.
|
||||||
//const baseline_from_bottom: f64 = @floatFromInt(self.metrics.cell_baseline);
|
|
||||||
const baseline_from_bottom: f64 = @floatFromInt(metrics.cell_baseline);
|
const baseline_from_bottom: f64 = @floatFromInt(metrics.cell_baseline);
|
||||||
|
|
||||||
// Next we offset our baseline by the bearing in the font. We
|
// Next we offset our baseline by the bearing in the font. We
|
||||||
|
@ -304,19 +304,16 @@ pub const Shaper = struct {
|
|||||||
|
|
||||||
// Get our glyphs and positions
|
// Get our glyphs and positions
|
||||||
const glyphs = try ctrun.getGlyphs(alloc);
|
const glyphs = try ctrun.getGlyphs(alloc);
|
||||||
const positions = try ctrun.getPositions(alloc);
|
|
||||||
const advances = try ctrun.getAdvances(alloc);
|
const advances = try ctrun.getAdvances(alloc);
|
||||||
const indices = try ctrun.getStringIndices(alloc);
|
const indices = try ctrun.getStringIndices(alloc);
|
||||||
assert(glyphs.len == positions.len);
|
|
||||||
assert(glyphs.len == advances.len);
|
assert(glyphs.len == advances.len);
|
||||||
assert(glyphs.len == indices.len);
|
assert(glyphs.len == indices.len);
|
||||||
|
|
||||||
for (
|
for (
|
||||||
glyphs,
|
glyphs,
|
||||||
positions,
|
|
||||||
advances,
|
advances,
|
||||||
indices,
|
indices,
|
||||||
) |glyph, pos, advance, index| {
|
) |glyph, advance, index| {
|
||||||
try self.cell_buf.ensureUnusedCapacity(
|
try self.cell_buf.ensureUnusedCapacity(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
glyphs.len,
|
glyphs.len,
|
||||||
@ -351,15 +348,7 @@ pub const Shaper = struct {
|
|||||||
// Advances apply to the NEXT cell.
|
// Advances apply to the NEXT cell.
|
||||||
cell_offset.x += advance.width;
|
cell_offset.x += advance.width;
|
||||||
cell_offset.y += advance.height;
|
cell_offset.y += advance.height;
|
||||||
|
|
||||||
_ = pos;
|
|
||||||
// const i = self.cell_buf.items.len - 1;
|
|
||||||
// log.warn(
|
|
||||||
// "i={} codepoint={} glyph={} pos={} advance={} index={} cluster={}",
|
|
||||||
// .{ i, self.codepoints.items[index].codepoint, glyph, pos, advance, index, cluster },
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
//log.warn("-------------------------------", .{});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If our last cell doesn't match our last cluster then we have
|
// If our last cell doesn't match our last cluster then we have
|
||||||
|
Reference in New Issue
Block a user