[draw] Add VARC tests

This commit is contained in:
Behdad Esfahbod committed 2026-02-12 15:26:19 -07:00
1 parent 7bbc027e11
commit e6346b63bf
7 files changed
+45 -4

No files matched your search

@@ -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
@@ -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
+8
View File
@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -800 1840 1000" width="1840" height="1000">
<defs>
<path id="g1" transform="scale(1 -1)" d="M83.45,118.5Q186.08,148.14 265.18,198.36Q344.27,248.59 398.25,318.95Q452.23,389.31 480.07,479.28Q507.91,569.25 507.91,678.17L507.91,722L80,722L80,652L463.43,652L428.29,664Q428.05,575.16 404.72,499.38Q381.39,423.61 334.68,362.23Q287.98,300.85 216.95,254.48Q145.93,208.12 50.21,177.42L83.45,118.5ZM702,400L887,400L887,470L702,470L702,400ZM666,-82L742,-82L742,803L666,803L666,-82Z"/>
<path id="g2" transform="scale(1 -1)" d="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.12ZM709,508.01L894,508.01L894,578.01L709,578.01L709,508.01ZM673,285.74L749,285.74L749,803L673,803L673,285.74ZM749.14,-93.48L749.14,186L749.14,236L196,236L196,166L712.14,166L674.69,182L674.69,-93.48L749.14,-93.48Z"/>
</defs>
<use href="#g1" transform="translate(0 0)"/>
<use href="#g2" transform="translate(920 0)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -800 1840 1000" width="1840" height="1000">
<defs>
<path id="g1" transform="scale(1 -1)" d="M80.52,98.57Q189.32,128.45 272.64,180.18Q355.95,231.91 412.77,304.91Q469.6,377.92 498.76,471.4Q527.91,564.88 527.91,678.3L527.91,742L67.45,742L67.45,608L449.12,608L378.24,656.24Q378.12,575.07 356.22,506.68Q334.32,438.3 290.03,383.05Q245.74,327.8 178.16,284.99Q110.57,242.18 18.37,211.67L80.52,98.57ZM702,370L907,370L907,500L702,500L702,370ZM616,-102L762,-102L762,823L616,823L616,-102Z"/>
<path id="g2" transform="scale(1 -1)" d="M78.31,273.3Q191.35,293.88 275.6,331.46Q359.86,369.05 415.9,423.76Q471.94,478.48 499.93,549.95Q527.91,621.41 527.91,709.77L527.91,766L64.49,766L64.49,637L455.4,637L376.23,687.31Q375.97,633.07 354.68,587.36Q333.39,541.65 290.83,504.92Q248.27,468.19 183.62,440.29Q118.96,412.38 31.55,393.24L78.31,273.3ZM709,487.99L914,487.99L914,617.99L709,617.99L709,487.99ZM623,292.63L769,292.63L769,823L623,823L623,292.63ZM769.14,-113.07L769.14,176L769.14,246L176,246L176,120L667.41,120L624.73,130L624.73,-113.07L769.14,-113.07Z"/>
</defs>
<use href="#g1" transform="translate(0 0)"/>
<use href="#g2" transform="translate(920 0)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+5
View File
@@ -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
+1
View File
@@ -2,6 +2,7 @@ run_test = find_program('run-tests.py')
tests = [
'basic',
'varc',
]
foreach t : tests
+21 -4
View File
@@ -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}")