font/shaper: split ligature around cell style change

This commit is contained in:
Mitchell Hashimoto
2023-08-29 14:09:21 -07:00
parent ae0de7bce4
commit ed5c001690
4 changed files with 135 additions and 4 deletions

View File

@@ -218,6 +218,16 @@ pub const Cell = struct {
/// also be true. The grapheme code points can be looked up in the
/// screen grapheme map.
grapheme: bool = false,
/// Returns only the attributes related to style.
pub fn styleAttrs(self: @This()) @This() {
var copy = self;
copy.wide = false;
copy.wide_spacer_tail = false;
copy.wide_spacer_head = false;
copy.grapheme = false;
return copy;
}
} = .{},
/// True if the cell should be skipped for drawing
@@ -2666,6 +2676,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void {
switch (width) {
1 => {
const cell = row.getCellPtr(x);
cell.* = self.cursor.pen;
cell.char = @intCast(c);
grapheme.x = x;
@@ -2691,6 +2702,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void {
{
const cell = row.getCellPtr(x);
cell.* = self.cursor.pen;
cell.char = @intCast(c);
cell.attrs.wide = true;

View File

@@ -99,6 +99,10 @@ pub const RGB = struct {
g: u8 = 0,
b: u8 = 0,
pub fn eql(self: RGB, other: RGB) bool {
return self.r == other.r and self.g == other.g and self.b == other.b;
}
test "size" {
try std.testing.expectEqual(@as(usize, 24), @bitSizeOf(RGB));
try std.testing.expectEqual(@as(usize, 3), @sizeOf(RGB));