[avar] Never downgrade avar2: instance NULL/empty-VarStore fonts on the avar2 path

An avar version 2 table with a NULL varStore offset is legal and maps
like plain v1 — but partial-instancing it used to fail outright, because
the planner errored against the missing store. Rather than falling back
to the v1 instancing path (which rescales every variation store and is
not always bit-exact), keep such fonts on the avar2 path: mapping
entries that don't resolve to a real store row are normalized to
NO_VARIATIONS_INDEX, mirroring runtime get_delta semantics, and offset
compensation creates the needed delta rows on demand in an empty store.
The instance stays version 2 and bit-exact, and consumers that ignore
the v2 tail still see the renormalized v1 segment maps.

Adds a subset test with a null-VarStore variant of the RobotoDelta test
font; the instancing test fails outright without the fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Fable 5 committed 2026-08-15 11:48:03 -06:00
1 parent 860213ead3
commit 8cb96426e0
5 files changed
+34 -2

No files matched your search

+12 -2
View File
@@ -607,9 +607,14 @@ struct avar
#endif
}
/* An avar version 2 font is never downgraded to v1: even with a NULL
* varStore offset (legal; maps like plain v1) the avar2 subsetting path
* applies, with "no variation" semantics for rows that don't resolve —
* offset compensation then creates delta rows on demand. */
bool has_v2_data () const { return version.major > 1; }
/* Resolve the avar2 VarStore and VarIdxMap, for the subset planner. */
/* Resolve the avar2 VarStore and VarIdxMap, for the subset planner.
* Either pointer may be to the Null object (nullable offsets). */
bool get_v2_store_and_map (const ItemVariationStore **store,
const DeltaSetIndexMap **varidx_map) const
{
@@ -880,7 +885,12 @@ struct avar
* other variation tables by standard instancing at the plan's
* axes_location/normalized_coords. */
/* 5. Build per-axis varIdx mapping (may create new VarDatas) */
/* 5. Build per-axis varIdx mapping (may create new VarDatas).
* Entries (or the implicit identity mapping) that don't resolve to a
* real store row behave as "no variation" at runtime; normalize them to
* NO_VARIATIONS_INDEX so the offset loop creates fresh rows instead of
* writing into nonexistent ones. This also covers a NULL VarStore
* (never downgraded: rows are created on demand). */
hb_vector_t<uint32_t> new_varidx_mapping;
if (!new_varidx_mapping.resize (axisCount)) return false;
for (unsigned i = 0; i < axisCount; i++)
@@ -0,0 +1,21 @@
# An avar version 2 table with a NULL VarStore offset is legal and maps
# like plain avar v1 — but it is never downgraded: partial instancing
# takes the avar2 path and creates offset-compensation rows on demand.
# This used to fail outright (the planner errored on the missing store).
FONTS:
RobotoDelta-NullVarStore-VF.ttf
PROFILES:
default.txt
SUBSETS:
*
INSTANCES:
wght=300:400:600
IUP_OPTIONS:
Yes
OPTIONS:
no_fonttools
+1
View File
@@ -88,6 +88,7 @@ tests = [
'colrv1_partial_instance',
'instantiate_gvar_padding',
'avar2_full_instance',
'avar2_null_varstore_partial_instance',
'subset_gvar_padding',
]