The vector util was creating a separate upem-scaled font clone, converting all shaping positions from font-scale to upem, and setting scale_factor to upem/font_size to undo that on emit. Simplify: use the caller's font directly. Positions from shaping are stored as-is (in font-scale = pixel * SCALE). scale_factor is just SCALE (= 1 << subpixel_bits), so the lib divides by SCALE on emit to produce pixel-space output. This removes ~40 lines: the upem_font creation, variation coord copying, scale_to_upem_x/y helpers, and the complex upem_per_pixel margin/stroke conversions. Margin conversion simplifies from margin * upem * SCALE / x_scale to just margin * SCALE. Regenerated vector test expected outputs for the new coordinate space. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adding tests
test/vector validates hb-vector CLI output by comparing exact stdout with
golden files.
Test file format (data/tests/*.tests)
Each non-empty, non-comment line has 4 semicolon-separated fields:
font-file;options;unicodes;expected-file
font-file: relative to the.testsfile (or absolute path).options: shell-split arguments passed tohb-vector.unicodes: Unicode sequence, using shape-style codepoint format (for exampleU+0061,U+0062,U+0063).expected-file: path to golden output, relative to the.testsfile. This is also used as the TAP test name.
Example:
../../../api/fonts/Roboto-Regular.abc.ttf;--font-size=64;U+0061,U+0062,U+0063;../expected/basic/reuse-svg.svg
Running vector tests
In an in-tree build:
meson test -C build-default -v --suite vector
Updating expected output
Regenerate a golden file with the current hb-vector binary and replace the
file under data/expected/.
Recording a new test case
Use record-test.sh:
./record-test.sh -o data/tests/basic.tests --test-name reuse-svg ../../build-default/util/hb-vector ../api/fonts/Roboto-Regular.abc.ttf --font-size=64 abc
It subsets the input font, verifies subset-vs-original rendering with
hb-view, stores the subset font under ../fonts/<sha1>.ttf (relative to the target
.tests file), writes expected output under
../expected/<tests-stem>/<test-name>.<ext> by default (unless
--expected-dir or --expected-file is provided), and
appends one test line to the target .tests file. hb-shape, hb-view, and
hb-subset are resolved as sibling executables next to the provided
hb-vector binary. The emitted test line uses Unicode codepoint input in the
unicodes field.