Files
harfbuzz/test/shape
Behdad Esfahbod 90417543fd [aat] Match CoreText kerx format 1 history (#6540)
* [test] Probe CoreText kerx stack behavior

Add native CoreText probes for list reuse, excess values, zero values,
duplicate pushes, repeated actions, resets, and long lists. Run them on
macOS 15 and macOS latest to establish the compatibility behavior before
changing the kerx driver.

The local baseline Meson suite passes all 275 tests. Native execution
is intentionally checked by the new macOS probe jobs.

Related: https://github.com/harfbuzz/harfbuzz/pull/6538#issuecomment-6561986849
Assisted-by: OpenAI Codex

* [test] Probe retained kerx history past eight pushes

Add an end-of-text action after twenty repeated push/action entries to
distinguish retained history from an eight-entry rolling window.

The local Meson suite passes all 275 tests.

Assisted-by: OpenAI Codex

* [test] Probe kerx history wraparound and reset reuse

Add native cases around the eight-slot boundary, actions before the
first push, a first push after ignored glyphs, and history reuse after
reset. These distinguish partial-history initialization and cursor
wraparound for the CoreText compatibility implementation.

Testing: all 275 Meson tests pass with the implementation in progress.

Assisted-by: OpenAI Codex

* [test] Verify kerx reset anchors and Arabic examples in CoreText

Measure a reset followed by another action without a push, and include
both versions of the reported Arabic font. Use mapped glyphs for ignored
prefixes so font fallback cannot affect the native position comparison.

Testing: all 275 Meson tests pass with the implementation in progress.

Assisted-by: OpenAI Codex

* [test] Probe long kerx lists after resetting history

Distinguish how reset initializes unused history slots by applying a
long list after a reset with and without a push, and after every push.

Testing: all 275 Meson tests pass with the implementation in progress.

Assisted-by: OpenAI Codex

* [aat] Match CoreText kerx format 1 history

The written kerx rules describe destructive stack pops and a reset flag.
Native CoreText retains an eight-slot circular history, initializes its
unused slots to the first glyph, and ignores reset. Each action list
walks the history independently and wraps after eight values.

Use that behavior for extended kerx while retaining legacy kern rules.
Bound the longer action-list walks by the buffer operation budget and
keep fixed-size history storage. Document the spec discrepancy and add
regressions for reuse, wraparound, initial slots, reset, and both Arabic
examples, plus terminated and unterminated over-budget lists.

Testing: all 275 Meson tests pass. HB and HR match glyph identities,
character indices, positions, and final extents for all 35 native cases
on macOS 15.8.2 and 26.6.2. Both Arabic examples match their GPOS reference.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6536
Assisted-by: OpenAI Codex

* [ci] Remove exploratory CoreText kerx probe jobs

The native measurements established the compatibility behavior, which
is now covered by the normal shaping regressions in HB and HR. Keep the
manual probe, recorded results, and discrepancy documentation without
adding two native macOS jobs to every pull request.

CI and documentation only; no code or test inputs changed.

Assisted-by: OpenAI Codex

* [test] Run kerx CoreText comparisons with shaping tests

Move the native helper and reference data from .ci into test/shape.
Run the native comparison as a normal CoreText-enabled macOS Meson
shaping test, using the existing macOS CI job. Keep the discrepancy
explanation beside the regression cases and drop the standalone Markdown.

Testing: all 275 Linux Meson tests pass. The comparison runner passes
all 35 recorded cases and rejects an injected position mismatch. The
native helper is unchanged from the macOS 15.8.2 and 26.6.2 measurements.

Assisted-by: OpenAI Codex

* [test] Keep kerx regressions in the shaping suite

Remove the API C budget test, native CoreText C helper, comparison
runner, reference JSON files, and extra Meson test target. Retain the
library fix and normal shaping regressions, with a short explanation of
the native behavior in the shaping test file.

Testing: all 275 Meson tests pass.

Assisted-by: OpenAI Codex
2026-11-01 13:35:37 -07:00
..
2021-08-11 18:49:59 -06:00
2021-08-11 18:49:59 -06:00
2025-06-14 11:02:37 -06:00

Adding tests

You can test shaping of a unicode sequence against a font like this:

$ ./hb-unicode-encode 41 42 43 627 | ../../util/hb-shape font.ttf

assuming an in-tree build. The 41 42 43 627 here is a sequence of Unicode codepoints: U+0041,0042,0043,0627. When you are happy with the shape results, you can use the record-test.sh script to add this to the test suite. record-test.sh requires pyftsubset to be installed. You can get pyftsubset by installing FontTools from https://github.com/behdad/fonttools.

To use record-test.sh, just put it right before the hb-shape invocation:

$ ./hb-unicode-encode 41 42 43 627 | ./record-test.sh ../../util/hb-shape font.ttf

hb-subset and hb-view are resolved as sibling executables next to the provided hb-shape binary.

what this does is:

  • Subset the font for the sequence of Unicode characters requested,
  • Compare the hb-shape output of the original font versus the subset font for the input sequence,
  • If the outputs differ, perhaps it is because the font does not have glyph names; it then compares the output of hb-view for both fonts.
  • If the outputs differ, recording fails. Otherwise, it will move the subset font file into data/in-house/fonts and name it after its hash, and print out the test case input, which you can then redirect to an existing or new test file in data/in-house/tests using -o, e.g.:
$ ./hb-unicode-encode 41 42 43 627 | ./record-test.sh -o data/in-house/tests/test-name.tests ../../util/hb-shape font.ttf

If you created a new test file, add it to data/in-house/meson.build so it is run. Check that make check does indeed run it, and that the test passes. When everything looks good, git add the new font as well as the new test file if you created any. You can see what new files are there by running git status data/in-house. And commit!

Note! Please only add tests using Open Source fonts, preferably under OFL or similar license.