Skip to content

Fix TrueTypeInterpreter pool state pollution#541

Merged
JimBobSquarePants merged 2 commits into
mainfrom
js/interpreter-pool-reset
Jul 5, 2026
Merged

Fix TrueTypeInterpreter pool state pollution#541
JimBobSquarePants merged 2 commits into
mainfrom
js/interpreter-pool-reset

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Replaces #540

@christianrondeau I couldn't push to your fork (I think because you are an org) so I replicated your commit here to ensure you have co-ownership.

This pull request improves the determinism and correctness of the TrueType hinting engine by ensuring that the interpreter's state is fully reset between renders, preventing non-deterministic output when reusing interpreters from a pool. It also improves CVT scaling precision and adds a regression test to guarantee consistent results. The most important changes are:

TrueType Interpreter State Management:

  • Updated SetControlValueTable in TrueTypeInterpreter.cs to always run the prep program even if the CVT table is missing, and to fully reset interpreter state (twilight zone, storage, rounding, zone pointers, etc.) before each prep execution, matching FreeType's behavior and preventing history-dependent, non-deterministic hinting results. [1] [2]

Hinting Precision:

  • Improved CVT value scaling to use 26.6 fixed-point rounding, matching FreeType and avoiding subtle rounding errors that could affect glyph rendering.

Testing and Robustness:

  • Added a regression test Hinting_OutputIsIndependentOfPreviouslyRenderedSizes in HintingTests.cs to ensure that rendering output is independent of previously rendered sizes and interpreter reuse. [1] [2]
  • Updated the reference output image for the hinting robustness test to reflect the corrected, deterministic rendering.

christianrondeau and others added 2 commits July 3, 2026 13:26
Align TrueType prep execution with FreeType behavior to improve deterministic hinting. This removes the saved post-fpgm storage baseline, clears storage before each prep run, and ensures prep still runs when no CVT table is present. CVT scaling now rounds to 26.6 fixed-point precision to avoid size-dependent rounding drift (notably in Arial at 13 ppem). The Arial hinting robustness reference image was updated to match the corrected output.
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84%. Comparing base (0d7e223) to head (ae7e3aa).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...nts/Tables/TrueType/Hinting/TrueTypeInterpreter.cs 89% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #541   +/-   ##
=====================================
  Coverage     84%     84%           
=====================================
  Files        332     332           
  Lines      24668   24684   +16     
  Branches    3611    3612    +1     
=====================================
+ Hits       20771   20785   +14     
- Misses      3010    3011    +1     
- Partials     887     888    +1     
Flag Coverage Δ
unittests 84% <89%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JimBobSquarePants JimBobSquarePants merged commit 18925d5 into main Jul 5, 2026
12 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/interpreter-pool-reset branch July 5, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants