font: add test for fl lig

This commit is contained in:
Mitchell Hashimoto
2024-08-11 15:04:56 -07:00
parent 956b097786
commit de9ea2d735
3 changed files with 35 additions and 1 deletions

Binary file not shown.

View File

@ -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,

View File

@ -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");