[test/shape] Respect @face-loaders directive

This commit is contained in:
Behdad Esfahbod 2025-04-06 14:33:44 -06:00
parent 1f1cbb64ee
commit 8456c33ac3
2 changed files with 74 additions and 65 deletions

View file

@ -1,11 +1,10 @@
# https://github.com/harfbuzz/harfbuzz/issues/5142
@shapers=ot,coretext
@face-loaders=ot,coretext
/System/Library/Fonts/SFNS.ttf;;U+0068,U+0065,U+006C,U+006C,U+006F;[h=0+1104|e=1+1049|l=2+418|l=3+418|o=4+1087]
/System/Library/Fonts/SFNS.ttf;--face-loader=coretext;U+0068,U+0065,U+006C,U+006C,U+006F;[h=0+1104|e=1+1049|l=2+418|l=3+418|o=4+1087]
/System/Library/Fonts/SFNSItalic.ttf;;U+0068,U+0065,U+006C,U+006C,U+006F;[h=0+1110|e=1+1062|l=2+424|l=3+424|o=4+1096]
/System/Library/Fonts/SFNSItalic.ttf;--face-loader=coretext;U+0068,U+0065,U+006C,U+006C,U+006F;[h=0+1110|e=1+1062|l=2+424|l=3+424|o=4+1096]
@shapers=ot # One day get most run through CoreText too
@face-loaders=ot
@shapers=ot # On day get most run through CoreText too
# https://github.com/harfbuzz/harfbuzz/issues/5232
/System/Library/Fonts/LucidaGrande.ttc;;U+05E8,U+05B0,U+05EA,U+05BC,U+05B4,U+05D9,U+05D5;[vavhebrew=6+655|yodhebrew=5+650|hiriqhebrew=2@81,0+0|tavdageshhebrew=2+1421|reshshevahebrew=0+1044]

View file

@ -140,6 +140,7 @@ for filename in args:
for what in ["shaper", "face-loader", "font-funcs"]:
all_var_name = all_whats_var_name(what)
globals()[all_var_name] = supported_whats(what)
all_face_loaders = ["ot"] # But only 'ot' face-loader
all_shapers = ["ot"] # But only 'ot' shaper
# Right now we only test the 'ot' shaper if nothing specified,
@ -258,77 +259,86 @@ for filename in args:
continue
options = new_options
for shaper in [shaper] if shaper else all_whats("shaper"):
for font_funcs in [font_funcs] if font_funcs else all_whats("font-funcs"):
number += 1
extra_options = []
for face_loader in [face_loader] if face_loader else all_whats("face-loader"):
for shaper in [shaper] if shaper else all_whats("shaper"):
for font_funcs in (
[font_funcs] if font_funcs else all_whats("font-funcs")
):
number += 1
extra_options = []
if shaper:
extra_options.append("--shaper=" + shaper)
if face_loader:
extra_options.append("--face-loader=" + face_loader)
if font_funcs:
extra_options.append("--font-funcs=" + font_funcs)
if shaper:
extra_options.append("--shaper=" + shaper)
if face_loader:
extra_options.append("--face-loader=" + face_loader)
if font_funcs:
extra_options.append("--font-funcs=" + font_funcs)
if glyphs_expected != "*":
extra_options.append("--verify")
extra_options.append("--unsafe-to-concat")
if glyphs_expected != "*":
extra_options.append("--verify")
extra_options.append("--unsafe-to-concat")
if verbose:
print(
"# shaper=%s face-loader=%s font-funcs=%s"
% (shaper, face_loader, font_funcs)
if verbose:
print(
"# shaper=%s face-loader=%s font-funcs=%s"
% (shaper, face_loader, font_funcs)
)
cmd = (
[fontfile] + ["--unicodes", unicodes] + options + extra_options
)
cmd = [fontfile] + ["--unicodes", unicodes] + options + extra_options
glyphs = shape_cmd(cmd, shape_process, verbose).strip()
glyphs = shape_cmd(cmd, shape_process, verbose).strip()
if glyphs_expected == "*":
passes += 1
print(f"ok {number} - {fontfile}")
continue
if glyphs_expected == "*":
passes += 1
print(f"ok {number} - {fontfile}")
continue
final_glyphs = glyphs
final_glyphs_expected = glyphs_expected
final_glyphs = glyphs
final_glyphs_expected = glyphs_expected
if glyphs != glyphs_expected and glyphs.find("gid") != -1:
if not no_glyph_names_process:
no_glyph_names_process = open_shape_batch_process()
if glyphs != glyphs_expected and glyphs.find("gid") != -1:
if not no_glyph_names_process:
no_glyph_names_process = open_shape_batch_process()
cmd2 = [fontfile] + ["--glyphs", "--no-glyph-names", glyphs]
final_glyphs = shape_cmd(cmd2, no_glyph_names_process).strip()
cmd2 = [fontfile] + ["--glyphs", "--no-glyph-names", glyphs]
final_glyphs = shape_cmd(cmd2, no_glyph_names_process).strip()
cmd2 = [fontfile] + [
"--glyphs",
"--no-glyph-names",
glyphs_expected,
]
final_glyphs_expected = shape_cmd(
cmd2, no_glyph_names_process
).strip()
cmd2 = [fontfile] + [
"--glyphs",
"--no-glyph-names",
glyphs_expected,
]
final_glyphs_expected = shape_cmd(
cmd2, no_glyph_names_process
).strip()
# If the removal of glyph_ids failed, fail the test.
# https://github.com/harfbuzz/harfbuzz/issues/5169
if not final_glyphs_expected or final_glyphs != final_glyphs_expected:
fails += 1
cmd = hb_shape + " " + " ".join(cmd)
print(f"not ok {number} - {cmd}")
print(" ---", file=sys.stderr)
print(' test_file: "' + filename + '"', file=sys.stderr)
print(' cmd: "' + cmd + '"', file=sys.stderr)
print(' actual: "' + glyphs + '"', file=sys.stderr)
print(' expected: "' + glyphs_expected + '"', file=sys.stderr)
if final_glyphs != glyphs:
print(
' actual_gids: "' + final_glyphs + '"', file=sys.stderr
)
print(
' expected_gids: "' + final_glyphs_expected + '"',
file=sys.stderr,
)
print(" ...", file=sys.stderr)
else:
passes += 1
print(f"ok {number} - {fontfile}")
# If the removal of glyph_ids failed, fail the test.
# https://github.com/harfbuzz/harfbuzz/issues/5169
if (
not final_glyphs_expected
or final_glyphs != final_glyphs_expected
):
fails += 1
cmd = hb_shape + " " + " ".join(cmd)
print(f"not ok {number} - {cmd}")
print(" ---", file=sys.stderr)
print(' test_file: "' + filename + '"', file=sys.stderr)
print(' cmd: "' + cmd + '"', file=sys.stderr)
print(' actual: "' + glyphs + '"', file=sys.stderr)
print(' expected: "' + glyphs_expected + '"', file=sys.stderr)
if final_glyphs != glyphs:
print(
' actual_gids: "' + final_glyphs + '"',
file=sys.stderr,
)
print(
' expected_gids: "' + final_glyphs_expected + '"',
file=sys.stderr,
)
print(" ...", file=sys.stderr)
else:
passes += 1
print(f"ok {number} - {fontfile}")
print("1..%d" % number)