From e6346b63bf9a02ffc745d0276bd3970f65c07559 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 9 Feb 2026 01:23:55 -0700 Subject: [PATCH] [draw] Add VARC tests --- .../expected/varc/conditional-default.txt | 1 + .../data/expected/varc/conditional-opsz1.txt | 1 + test/draw/data/expected/varc/default.svg | 8 ++++++ test/draw/data/expected/varc/wght840p3.svg | 8 ++++++ test/draw/data/tests/varc.tests | 5 ++++ test/draw/meson.build | 1 + test/draw/run-tests.py | 25 ++++++++++++++++--- 7 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 test/draw/data/expected/varc/conditional-default.txt create mode 100644 test/draw/data/expected/varc/conditional-opsz1.txt create mode 100644 test/draw/data/expected/varc/default.svg create mode 100644 test/draw/data/expected/varc/wght840p3.svg create mode 100644 test/draw/data/tests/varc.tests diff --git a/test/draw/data/expected/varc/conditional-default.txt b/test/draw/data/expected/varc/conditional-default.txt new file mode 100644 index 000000000..b04a9ea89 --- /dev/null +++ b/test/draw/data/expected/varc/conditional-default.txt @@ -0,0 +1 @@ +M85.86,-284.12Q191.24,-304.99 270.31,-341.96Q349.37,-378.92 402.13,-432.04Q454.88,-485.16 481.39,-554.48Q507.9,-623.79 507.9,-709.05L507.9,-746L80,-746L80,-676L463.82,-676L426.44,-688Q425.94,-625 403.09,-571.44Q380.24,-517.89 334.68,-474.9Q289.13,-431.9 220.17,-399.75Q151.2,-367.6 58.78,-346.97L85.86,-284.12ZM749.14,93.48L749.14,-186L749.14,-236L196,-236L196,-166L712.14,-166L674.69,-182L674.69,93.48L749.14,93.48Z diff --git a/test/draw/data/expected/varc/conditional-opsz1.txt b/test/draw/data/expected/varc/conditional-opsz1.txt new file mode 100644 index 000000000..6035ca9a9 --- /dev/null +++ b/test/draw/data/expected/varc/conditional-opsz1.txt @@ -0,0 +1 @@ +M85.27,-284.07Q190.51,-305.66 269.65,-343.75Q348.79,-381.83 401.7,-436.42Q454.61,-491.02 481.26,-562.1Q507.91,-633.18 507.91,-720.47L507.91,-758L80,-758L80,-688L463.8,-688L426.59,-700Q426.11,-634.79 403.2,-579.35Q380.29,-523.9 334.6,-479.35Q288.9,-434.79 219.7,-401.45Q150.5,-368.1 57.71,-346.64L85.27,-284.07ZM749.23,93.48L749.23,-186L749.23,-236L144,-236L144,-166L712.37,-166L674.78,-182L674.78,93.48L749.23,93.48Z diff --git a/test/draw/data/expected/varc/default.svg b/test/draw/data/expected/varc/default.svg new file mode 100644 index 000000000..32a79bce3 --- /dev/null +++ b/test/draw/data/expected/varc/default.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/test/draw/data/expected/varc/wght840p3.svg b/test/draw/data/expected/varc/wght840p3.svg new file mode 100644 index 000000000..250aba13d --- /dev/null +++ b/test/draw/data/expected/varc/wght840p3.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/test/draw/data/tests/varc.tests b/test/draw/data/tests/varc.tests new file mode 100644 index 000000000..d0cd67b3b --- /dev/null +++ b/test/draw/data/tests/varc.tests @@ -0,0 +1,5 @@ +# font-file;options;unicodes;expected-file +../../../api/fonts/varc-ac00-ac01.ttf;;U+AC00,U+AC01;../expected/varc/default.svg +../../../api/fonts/varc-ac00-ac01.ttf;--variations=wght=840.3;U+AC00,U+AC01;../expected/varc/wght840p3.svg +../../../api/fonts/varc-ac01-conditional.ttf;-q;U+AC01;../expected/varc/conditional-default.txt +../../../api/fonts/varc-ac01-conditional.ttf;-q --variations=opsz=1;U+AC01;../expected/varc/conditional-opsz1.txt diff --git a/test/draw/meson.build b/test/draw/meson.build index ff800437f..1e0d06d40 100644 --- a/test/draw/meson.build +++ b/test/draw/meson.build @@ -2,6 +2,7 @@ run_test = find_program('run-tests.py') tests = [ 'basic', + 'varc', ] foreach t : tests diff --git a/test/draw/run-tests.py b/test/draw/run-tests.py index 6dc51b6b9..0342af26f 100755 --- a/test/draw/run-tests.py +++ b/test/draw/run-tests.py @@ -28,11 +28,28 @@ def resolve_path(base, path): return os.path.normpath(os.path.join(base, path)) -def run_draw(font_path, options, text): +def run_draw(font_path, options, text, unicodes): cmd = [hb_draw] + option_argv = [] if options: - cmd.extend(shlex.split(options)) - cmd.extend([font_path, text]) + option_argv = shlex.split(options) + cmd.extend(option_argv) + + # Prefer --unicodes to keep argv ASCII and avoid locale-dependent UTF-8 + # decoding failures when LC_ALL=C. + has_text_input_option = False + for opt in option_argv: + if opt in ("-t", "--text", "-u", "--unicodes"): + has_text_input_option = True + break + if opt.startswith("--text=") or opt.startswith("--unicodes="): + has_text_input_option = True + break + + if has_text_input_option: + cmd.extend([font_path, text]) + else: + cmd.extend([f"--unicodes={unicodes}", font_path]) if EXE_WRAPPER: cmd = [EXE_WRAPPER] + cmd return subprocess.run(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) @@ -99,7 +116,7 @@ for filename in args: print("# " + str(e)) continue - result = run_draw(font_path, options, text) + result = run_draw(font_path, options, text, unicodes) if result.returncode != 0: fails += 1 print(f"not ok {number} - {name}")