diff --git a/src/font/res/CodeNewRoman-Regular.otf b/src/font/res/CodeNewRoman-Regular.otf new file mode 100644 index 000000000..dcc7c3570 Binary files /dev/null and b/src/font/res/CodeNewRoman-Regular.otf differ diff --git a/src/font/shaper/coretext.zig b/src/font/shaper/coretext.zig index 841b6b5e9..1305a1b4a 100644 --- a/src/font/shaper/coretext.zig +++ b/src/font/shaper/coretext.zig @@ -913,6 +913,37 @@ test "shape monaspace ligs" { } } +// This font has an undesirable "fl" lig but we want to +// ensure we get it so that we can test for it. +test "shape fl lig" { + const testing = std.testing; + const alloc = testing.allocator; + + var testdata = try testShaperWithFont(alloc, .code_new_roman); + defer testdata.deinit(); + + // Make a screen with some data + var screen = try terminal.Screen.init(alloc, 10, 3, 0); + defer screen.deinit(); + try screen.testWriteString("fl"); + + // Get our run iterator + var shaper = &testdata.shaper; + var it = shaper.runIterator( + testdata.grid, + &screen, + screen.pages.pin(.{ .screen = .{ .y = 0 } }).?, + null, + null, + ); + const run = (try it.next(alloc)).?; + try testing.expect((try it.next(alloc)) == null); + const cells = try shaper.shape(run); + try testing.expectEqual(@as(usize, 2), cells.len); + try testing.expect(cells[0].glyph_index != null); + try testing.expect(cells[1].glyph_index == null); +} + // https://github.com/mitchellh/ghostty/issues/1708 test "shape left-replaced lig in last run" { const testing = std.testing; @@ -1697,8 +1728,9 @@ const TestShaper = struct { }; const TestFont = enum { - inconsolata, + code_new_roman, geist_mono, + inconsolata, jetbrains_mono, monaspace_neon, nerd_font, @@ -1713,6 +1745,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper { const testEmoji = @import("../test.zig").fontEmoji; const testEmojiText = @import("../test.zig").fontEmojiText; const testFont = switch (font_req) { + .code_new_roman => @import("../test.zig").fontCodeNewRoman, .inconsolata => @import("../test.zig").fontRegular, .geist_mono => @import("../test.zig").fontGeistMono, .jetbrains_mono => @import("../test.zig").fontJetBrainsMono, diff --git a/src/font/test.zig b/src/font/test.zig index e5254b9a8..c7b68e5c6 100644 --- a/src/font/test.zig +++ b/src/font/test.zig @@ -16,6 +16,7 @@ pub const fontVariable = @embedFile("res/Lilex-VF.ttf"); pub const fontNerdFont = @embedFile("res/JetBrainsMonoNerdFont-Regular.ttf"); /// Specific font families below: +pub const fontCodeNewRoman = @embedFile("res/CodeNewRoman-Regular.otf"); pub const fontGeistMono = @embedFile("res/GeistMono-Regular.ttf"); pub const fontJetBrainsMono = @embedFile("res/JetBrainsMonoNoNF-Regular.ttf"); pub const fontJuliaMono = @embedFile("res/JuliaMono-Regular.ttf");