GPOS PairPosFormat1: device/VariationIndex offsets in PairValueRecords are resolved from the wrong base, so they are always dropped
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 67/100
Direzione di ricerca
Start with PairSet::parse and PairSet::get in src/tables/gpos.rs, then compare how ValueRecordsArray in SinglePos retains data for device offsets. Keep the PairSet's full data available when parsing ValueRecords while using the records slice for binary search. Done when the reproduction returns a VariationIndex device and the variation delta affects the pair adjustment.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In PairPosFormat1, a PairValueRecord's ValueRecord device offsets
are always lost: ValueRecord::x_advance_device (and the other three
device fields) come back None. In a variable font, every glyph-pair
kerning value with a variation delta is then read at its default value.
The OpenType spec (GPOS, Shared formats → Value record) says each
device offset is "from beginning of the immediate parent table
(SinglePos or PairPosFormat2 lookup subtable, PairSet table within a
PairPosFormat1 lookup subtable)".
PairSet::parse (src/tables/gpos.rs) keeps only the records' bytes
(s.read_bytes(count * record_len), after pairValueCount), and
PairSet::get passes those bytes to ValueRecord::parse as the table
data. A device offset is therefore resolved from 2 bytes past the
PairSet's start, inside a slice that ends with the records. A device
table placed after the records (where font compilers put it) is outside
that slice, so Device::parse gets nothing and the field is None.
PairPosFormat2 and SinglePos pass their subtable's data and are not
affected.
Reproduction. A font with one PairPosFormat1 pair (a, b): x advance
−30, plus a VariationIndex device (0, 0) whose delta is +30 at wght 900.
Font (fontTools):
# make_fonts.py, attached; excerpt
f = build("kerning-device", "languagesystem DFLT dflt; feature kern { pos a b -30; } kern;", var=True)
var_gdef(f, 30) # GDEF 1.3, ItemVariationStore entry (0, 0) = +30 at wght max
st = f["GPOS"].table.LookupList.Lookup[0].SubTable[0] # Format 1
st.ValueFormat1 |= 0x0040
st.PairSet[0].PairValueRecord[0].Value1.XAdvDevice = buildVarDevTable(0)
// ttf-parser = "=0.25.1"
use ttf_parser::gpos::{PairAdjustment, PositioningSubtable};
use ttf_parser::{Face, Tag};
let data = std::fs::read("kerning-device.ttf").unwrap();
let mut face = Face::parse(&data, 0).unwrap();
face.set_variation(Tag::from_bytes(b"wght"), 900.0).unwrap();
let (a, b) = (face.glyph_index('a').unwrap(), face.glyph_index('b').unwrap());
let st = face.tables().gpos.unwrap().lookups.get(0).unwrap().subtables.get::<PositioningSubtable>(0).unwrap();
let PositioningSubtable::Pair(PairAdjustment::Format1 { coverage, sets }) = st else { panic!() };
let (v1, _) = sets.get(coverage.get(a).unwrap()).unwrap().get(b).unwrap();
println!("{} {}", v1.x_advance, v1.x_advance_device.is_some());
println!("{:?}", face.tables().gdef.unwrap().glyph_variation_delta(0, 0, face.variation_coordinates()));
Output (0.25.1, and main at 0c7291223):
-30 false
Some(30.0)
Expected: x_advance_device is Some(Device::Variation { outer_index: 0, inner_index: 0 }), so the pair kerns −30 + 30 = 0 at wght 900.
HarfBuzz (uharfbuzz 0.57) shapes "ab" in this font with advances [570, 600] at wght 400 and [600, 600] at wght 900.
Fix: keep the PairSet's full data (from its start) for resolving
device offsets, separate from the records slice used for the binary
search, as ValueRecordsArray does for SinglePos.
Found while using ttf-parser 0.25.1 (font: Fredoka's variable font,
whose glyph-pair kerning goes to zero at its condensed width; ttf-parser
kept −30).
The fontTools excerpt above builds the font (GitHub doesn't accept .ttf attachments); happy to share the full script and font.
- Lingua principale
- Rust
- Stelle
- 798
- Fork
- 96
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di harfbuzz/ttf-parser
-
cmap format 4 drops glyph IDs above 32767 in the glyphIdArray pathForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
harfbuzz/ttf-parser#247 ·
-
chore: release 0.26.0Forse di nuovo libera @alerque l’ha presa 117 giorni fa e non c’è nessuna pull request aperta. Aperta
harfbuzz/ttf-parser#242 · 3 commenti · 1 reazione · 2 assegnatari ·
-
help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
harfbuzz/ttf-parser#241 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
harfbuzz/ttf-parser#230 · 26 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
harfbuzz/ttf-parser#217 · 6 commenti ·
Tutte le issue di harfbuzz/ttf-parser
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ardia-browser/ardia#5810 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
UIUX の修正Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
aptos-labs/aptos-core#21119 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 8 giorni