Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions scripts/gen-shaping-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@
# This custom test fails because harfbuzz uses a set digest in AAT to abort early
# which we don't do yet. Is basically the same as morx_20_005, but with `--show-flags`
"glyph_flags_002",

# These currently return different results from harfbuzz.
"colr_003",
"colr_006",
"colr_007",
"colr_008",
"colr_009",
"colr_010",
"colr_011",
"colr_012",
"colr_014",
"colr_015",
"colr_016",
"colr_018",
]


Expand Down Expand Up @@ -222,6 +236,8 @@ def convert_test_files(root_dir, hb_shape_exe, tests_dir, tests_name, files, cus
root_dir, hb_shape_exe, tests_name, file, idx + 1, test, fonts, custom
)

# Strip the extra trailing newline to avoid formatting churn
rust_code = rust_code[:-1]
tests_name_snake_case = tests_name.replace("-", "_")
with open(f"../tests/shaping/{tests_name_snake_case}.rs", "w") as f:
f.write(rust_code)
Expand Down
3 changes: 0 additions & 3 deletions src/hb/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ impl<'a> hb_font_t<'a> {
glyph_extents.height = (-f32::from(img.height) * scale).round() as i32;
return true;
}
// TODO: Add tests for this. We should use all glyphs from
// https://github.com/googlefonts/color-fonts/blob/main/fonts/test_glyphs-glyf_colr_1_no_cliplist.ttf
// and test their output against harfbuzz.
} else if let Some(colr) = self.ttfp_face.tables().colr {
if colr.is_simple() {
return false;
Expand Down
20 changes: 20 additions & 0 deletions tests/custom/colr.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0100,U+F0101,U+F0102,U+F0103;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0200,U+F0201,U+F0202,U+F0203,U+F0204,U+F0205,U+F0206,U+F0207,U+F0208,U+F0209,U+F020A,U+F020B,U+F020C,U+F020D,U+F020E,U+F020F,U+F0210,U+F0211,U+F0212,U+F0213,U+F0214,U+F0215,U+F0216,U+F0217,U+F0218,U+F0219,U+F021A,U+F021B,U+F021C,U+F021D,U+F021E,U+F021F,U+F0220,U+F0221,U+F0222,U+F0223,U+F0224,U+F0225,U+F0226,U+F0227,U+F0228,U+F0229,U+F022A,U+F022B,U+F022C,U+F022D,U+F022E,U+F022F,U+F0230,U+F0231,U+F0232,U+F0233,U+F0234,U+F0235,U+F0236,U+F0237,U+F0238,U+F0239,U+F023A,U+F023B,U+F023C,U+F023D,U+F023E,U+F023F,U+F0240,U+F0241,U+F0242,U+F0243,U+F0244,U+F0245,U+F0246,U+F0247;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0300,U+F0301,U+F0302,U+F0303,U+F0304,U+F0305;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0500,U+F0501,U+F0502;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0503,U+F0504,U+F0505,U+F0506,U+F0507,U+F0508;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0600,U+F0601,U+F0602,U+F0603;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0700,U+F0701,U+F0702,U+F0703,U+F0704,U+F0705;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0800,U+F0801,U+F0802,U+F0803;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0900,U+F0901,U+F0902,U+F0903,U+F0904,U+F0905,U+F0906;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0A00,U+F0A01,U+F0A02,U+F0A03,U+F0A04,U+F0A05,U+F0A06,U+F0A07,U+F0A08,U+F0A09,U+F0A0A,U+F0A0B,U+F0A0C,U+F0A0D,U+F0A0E,U+F0A0F,U+F0A10,U+F0A11,U+F0A12,U+F0A13,U+F0A14,U+F0A15,U+F0A16,U+F0A17,U+F0A18,U+F0A19,U+F0A1A,U+F0A1B;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0B00,U+F0B01,U+F0B02,U+F0B03,U+F0B04,U+F0B05,U+F0B06,U+F0B07;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0C00,U+F0C01,U+F0C02,U+F0C03,U+F0C04,U+F0C05,U+F0C06,U+F0C07,U+F0C08,U+F0C09,U+F0C0A;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0D00;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0E00,U+F0E01;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F0F00,U+F0F01,U+F0F02,U+F0F03,U+F0F04,U+F0F05,U+F0F06;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F1000;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F1100,U+F1101;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F1200;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F1300,U+F1301,U+F1302,U+F1303,U+F1304,U+F1305,U+F1306,U+F1307,U+F1308,U+F1309,U+F130A,U+F130B,U+F130C,U+F130D,U+F130E,U+F130F,U+F1310,U+F1311,U+F1312,U+F1313,U+F1314,U+F1315,U+F1316,U+F1317;
tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf;--show-extents;U+F1400,U+F1401,U+F1402,U+F1403,U+F1404,U+F1405,U+F1406,U+F1407,U+F1408,U+F1409,U+F140A,U+F140B,U+F140C,U+F140D,U+F140E,U+F140F;
Binary file not shown.
226 changes: 226 additions & 0 deletions tests/shaping/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,232 @@ fn bugs_003() {
);
}

#[test]
fn colr_001() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F0100}\u{F0101}\u{F0102}\u{F0103}",
"--show-extents",
),
"linear_repeat_0_1=0+1000<100,950,800,-700>|\
linear_repeat_0.2_0.8=1+1000<100,950,800,-700>|\
linear_repeat_0_1.5=2+1000<100,950,800,-700>|\
linear_repeat_0.5_1.5=3+1000<100,950,800,-700>"
);
}

#[test]
fn colr_002() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F0200}\u{F0201}\u{F0202}\u{F0203}\u{F0204}\u{F0205}\u{F0206}\u{F0207}\u{F0208}\u{F0209}\
\u{F020A}\u{F020B}\u{F020C}\u{F020D}\u{F020E}\u{F020F}\u{F0210}\u{F0211}\u{F0212}\u{F0213}\
\u{F0214}\u{F0215}\u{F0216}\u{F0217}\u{F0218}\u{F0219}\u{F021A}\u{F021B}\u{F021C}\u{F021D}\
\u{F021E}\u{F021F}\u{F0220}\u{F0221}\u{F0222}\u{F0223}\u{F0224}\u{F0225}\u{F0226}\u{F0227}\
\u{F0228}\u{F0229}\u{F022A}\u{F022B}\u{F022C}\u{F022D}\u{F022E}\u{F022F}\u{F0230}\u{F0231}\
\u{F0232}\u{F0233}\u{F0234}\u{F0235}\u{F0236}\u{F0237}\u{F0238}\u{F0239}\u{F023A}\u{F023B}\
\u{F023C}\u{F023D}\u{F023E}\u{F023F}\u{F0240}\u{F0241}\u{F0242}\u{F0243}\u{F0244}\u{F0245}\
\u{F0246}\u{F0247}",
"--show-extents",
),
"sweep_0_360_pad_narrow=0+1000<150,950,700,-700>|\
sweep_60_300_pad_narrow=1+1000<150,950,700,-700>|\
sweep_0_90_pad_narrow=2+1000<150,950,700,-700>|\
sweep_90_0_pad_narrow=3+1000<150,950,700,-700>|\
sweep_45_90_pad_narrow=4+1000<150,950,700,-700>|\
sweep_90_45_pad_narrow=5+1000<150,950,700,-700>|\
sweep_247.5_292.5_pad_narrow=6+1000<150,950,700,-700>|\
sweep_-45_45_pad_narrow=7+1000<150,950,700,-700>|\
sweep_45_-45_pad_narrow=8+1000<150,950,700,-700>|\
sweep_270_440_pad_narrow=9+1000<150,950,700,-700>|\
sweep_440_270_pad_narrow=10+1000<150,950,700,-700>|\
sweep_-180_540_pad_narrow=11+1000<150,950,700,-700>|\
sweep_0_360_reflect_narrow=12+1000<150,950,700,-700>|\
sweep_60_300_reflect_narrow=13+1000<150,950,700,-700>|\
sweep_0_90_reflect_narrow=14+1000<150,950,700,-700>|\
sweep_90_0_reflect_narrow=15+1000<150,950,700,-700>|\
sweep_45_90_reflect_narrow=16+1000<150,950,700,-700>|\
sweep_90_45_reflect_narrow=17+1000<150,950,700,-700>|\
sweep_247.5_292.5_reflect_narrow=18+1000<150,950,700,-700>|\
sweep_-45_45_reflect_narrow=19+1000<150,950,700,-700>|\
sweep_45_-45_reflect_narrow=20+1000<150,950,700,-700>|\
sweep_270_440_reflect_narrow=21+1000<150,950,700,-700>|\
sweep_440_270_reflect_narrow=22+1000<150,950,700,-700>|\
sweep_-180_540_reflect_narrow=23+1000<150,950,700,-700>|\
sweep_0_360_repeat_narrow=24+1000<150,950,700,-700>|\
sweep_60_300_repeat_narrow=25+1000<150,950,700,-700>|\
sweep_0_90_repeat_narrow=26+1000<150,950,700,-700>|\
sweep_90_0_repeat_narrow=27+1000<150,950,700,-700>|\
sweep_45_90_repeat_narrow=28+1000<150,950,700,-700>|\
sweep_90_45_repeat_narrow=29+1000<150,950,700,-700>|\
sweep_247.5_292.5_repeat_narrow=30+1000<150,950,700,-700>|\
sweep_-45_45_repeat_narrow=31+1000<150,950,700,-700>|\
sweep_45_-45_repeat_narrow=32+1000<150,950,700,-700>|\
sweep_270_440_repeat_narrow=33+1000<150,950,700,-700>|\
sweep_440_270_repeat_narrow=34+1000<150,950,700,-700>|\
sweep_-180_540_repeat_narrow=35+1000<150,950,700,-700>|\
sweep_0_360_pad_wide=36+1000<150,950,700,-700>|\
sweep_60_300_pad_wide=37+1000<150,950,700,-700>|\
sweep_0_90_pad_wide=38+1000<150,950,700,-700>|\
sweep_90_0_pad_wide=39+1000<150,950,700,-700>|\
sweep_45_90_pad_wide=40+1000<150,950,700,-700>|\
sweep_90_45_pad_wide=41+1000<150,950,700,-700>|\
sweep_247.5_292.5_pad_wide=42+1000<150,950,700,-700>|\
sweep_-45_45_pad_wide=43+1000<150,950,700,-700>|\
sweep_45_-45_pad_wide=44+1000<150,950,700,-700>|\
sweep_270_440_pad_wide=45+1000<150,950,700,-700>|\
sweep_440_270_pad_wide=46+1000<150,950,700,-700>|\
sweep_-180_540_pad_wide=47+1000<150,950,700,-700>|\
sweep_0_360_reflect_wide=48+1000<150,950,700,-700>|\
sweep_60_300_reflect_wide=49+1000<150,950,700,-700>|\
sweep_0_90_reflect_wide=50+1000<150,950,700,-700>|\
sweep_90_0_reflect_wide=51+1000<150,950,700,-700>|\
sweep_45_90_reflect_wide=52+1000<150,950,700,-700>|\
sweep_90_45_reflect_wide=53+1000<150,950,700,-700>|\
sweep_247.5_292.5_reflect_wide=54+1000<150,950,700,-700>|\
sweep_-45_45_reflect_wide=55+1000<150,950,700,-700>|\
sweep_45_-45_reflect_wide=56+1000<150,950,700,-700>|\
sweep_270_440_reflect_wide=57+1000<150,950,700,-700>|\
sweep_440_270_reflect_wide=58+1000<150,950,700,-700>|\
sweep_-180_540_reflect_wide=59+1000<150,950,700,-700>|\
sweep_0_360_repeat_wide=60+1000<150,950,700,-700>|\
sweep_60_300_repeat_wide=61+1000<150,950,700,-700>|\
sweep_0_90_repeat_wide=62+1000<150,950,700,-700>|\
sweep_90_0_repeat_wide=63+1000<150,950,700,-700>|\
sweep_45_90_repeat_wide=64+1000<150,950,700,-700>|\
sweep_90_45_repeat_wide=65+1000<150,950,700,-700>|\
sweep_247.5_292.5_repeat_wide=66+1000<150,950,700,-700>|\
sweep_-45_45_repeat_wide=67+1000<150,950,700,-700>|\
sweep_45_-45_repeat_wide=68+1000<150,950,700,-700>|\
sweep_270_440_repeat_wide=69+1000<150,950,700,-700>|\
sweep_440_270_repeat_wide=70+1000<150,950,700,-700>|\
sweep_-180_540_repeat_wide=71+1000<150,950,700,-700>"
);
}

#[test]
fn colr_004() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F0500}\u{F0501}\u{F0502}",
"--show-extents",
),
"linear_gradient_extend_mode_pad=0+1000<0,1000,1000,-1000>|\
linear_gradient_extend_mode_repeat=1+1000<0,1000,1000,-1000>|\
linear_gradient_extend_mode_reflect=2+1000<0,1000,1000,-1000>"
);
}

#[test]
fn colr_005() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F0503}\u{F0504}\u{F0505}\u{F0506}\u{F0507}\u{F0508}",
"--show-extents",
),
"radial_contained_gradient_extend_mode_pad=0+1000<0,1000,1000,-1000>|\
radial_contained_gradient_extend_mode_repeat=1+1000<0,1000,1000,-1000>|\
radial_contained_gradient_extend_mode_reflect=2+1000<0,1000,1000,-1000>|\
radial_horizontal_gradient_extend_mode_pad=3+1000<0,1000,1000,-1000>|\
radial_horizontal_gradient_extend_mode_repeat=4+1000<0,1000,1000,-1000>|\
radial_horizontal_gradient_extend_mode_reflect=5+1000<0,1000,1000,-1000>"
);
}

#[test]
fn colr_013() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F0D00}",
"--show-extents",
),
"gradient_p2_skewed=0+1250<100,950,1100,-700>"
);
}

#[test]
fn colr_017() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F1100}\u{F1101}",
"--show-extents",
),
"paintcolrglyph_cycle_first=0+1000<0,0,0,0>|\
paintcolrglyph_cycle_second=1+1000<0,0,0,0>"
);
}

#[test]
fn colr_019() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F1300}\u{F1301}\u{F1302}\u{F1303}\u{F1304}\u{F1305}\u{F1306}\u{F1307}\u{F1308}\u{F1309}\
\u{F130A}\u{F130B}\u{F130C}\u{F130D}\u{F130E}\u{F130F}\u{F1310}\u{F1311}\u{F1312}\u{F1313}\
\u{F1314}\u{F1315}\u{F1316}\u{F1317}",
"--show-extents",
),
"sweep_coincident_angles_forward_blue_red_pad=0+1000<150,950,700,-700>|\
sweep_coincident_angles_forward_blue_red_reflect=1+1000<150,950,700,-700>|\
sweep_coincident_angles_forward_blue_red_repeat=2+1000<150,950,700,-700>|\
sweep_coincident_angles_forward_linen_gray_pad=3+1000<150,950,700,-700>|\
sweep_coincident_angles_forward_linen_gray_reflect=4+1000<150,950,700,-700>|\
sweep_coincident_angles_forward_linen_gray_repeat=5+1000<150,950,700,-700>|\
sweep_coincident_angles_reverse_blue_red_pad=6+1000<150,950,700,-700>|\
sweep_coincident_angles_reverse_blue_red_reflect=7+1000<150,950,700,-700>|\
sweep_coincident_angles_reverse_blue_red_repeat=8+1000<150,950,700,-700>|\
sweep_coincident_angles_reverse_linen_gray_pad=9+1000<150,950,700,-700>|\
sweep_coincident_angles_reverse_linen_gray_reflect=10+1000<150,950,700,-700>|\
sweep_coincident_angles_reverse_linen_gray_repeat=11+1000<150,950,700,-700>|\
sweep_coincident_stops_forward_blue_red_pad=12+1000<150,950,700,-700>|\
sweep_coincident_stops_forward_blue_red_reflect=13+1000<150,950,700,-700>|\
sweep_coincident_stops_forward_blue_red_repeat=14+1000<150,950,700,-700>|\
sweep_coincident_stops_forward_linen_gray_pad=15+1000<150,950,700,-700>|\
sweep_coincident_stops_forward_linen_gray_reflect=16+1000<150,950,700,-700>|\
sweep_coincident_stops_forward_linen_gray_repeat=17+1000<150,950,700,-700>|\
sweep_coincident_stops_reverse_blue_red_pad=18+1000<150,950,700,-700>|\
sweep_coincident_stops_reverse_blue_red_reflect=19+1000<150,950,700,-700>|\
sweep_coincident_stops_reverse_blue_red_repeat=20+1000<150,950,700,-700>|\
sweep_coincident_stops_reverse_linen_gray_pad=21+1000<150,950,700,-700>|\
sweep_coincident_stops_reverse_linen_gray_reflect=22+1000<150,950,700,-700>|\
sweep_coincident_stops_reverse_linen_gray_repeat=23+1000<150,950,700,-700>"
);
}

#[test]
fn colr_020() {
assert_eq!(
shape(
"tests/fonts/rb_custom/test_glyphs-glyf_colr_1_no_cliplist.ttf",
"\u{F1400}\u{F1401}\u{F1402}\u{F1403}\u{F1404}\u{F1405}\u{F1406}\u{F1407}\u{F1408}\u{F1409}\
\u{F140A}\u{F140B}\u{F140C}\u{F140D}\u{F140E}\u{F140F}",
"--show-extents",
),
"paint_glyph_nested_identity_identity=0+1000<200,770,600,-520>|\
paint_glyph_nested_identity_translate=1+1000<200,770,600,-520>|\
paint_glyph_nested_identity_rotate_origin=2+1000<200,770,600,-520>|\
paint_glyph_nested_identity_rotate_center=3+1000<200,770,600,-520>|\
paint_glyph_nested_translate_identity=4+1000<320,890,600,-520>|\
paint_glyph_nested_translate_translate=5+1000<320,890,600,-520>|\
paint_glyph_nested_translate_rotate_origin=6+1000<320,890,600,-520>|\
paint_glyph_nested_translate_rotate_center=7+1000<320,890,600,-520>|\
paint_glyph_nested_rotate_origin_identity=8+1000<63,897,681,-616>|\
paint_glyph_nested_rotate_origin_translate=9+1000<63,897,681,-616>|\
paint_glyph_nested_rotate_origin_rotate_origin=10+1000<63,897,681,-616>|\
paint_glyph_nested_rotate_origin_rotate_center=11+1000<63,897,681,-616>|\
paint_glyph_nested_rotate_center_identity=12+1000<124,899,750,-779>|\
paint_glyph_nested_rotate_center_translate=13+1000<124,899,750,-779>|\
paint_glyph_nested_rotate_center_rotate_origin=14+1000<124,899,750,-779>|\
paint_glyph_nested_rotate_center_rotate_center=15+1000<124,899,750,-779>"
);
}

#[test]
fn fuzzer_001() {
assert_eq!(
Expand Down