GPOS PairPosFormat1: device/VariationIndex offsets in PairValueRecords are resolved from the wrong base, so they are always dropped
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Rust
- 星标
- 798
- 派生
- 96
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
harfbuzz/ttf-parser 的其他 Issue
-
cmap format 4 drops glyph IDs above 32767 in the glyphIdArray path可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
harfbuzz/ttf-parser#247 ·
-
chore: release 0.26.0可能重新可做 @alerque 于 117 天前认领,目前没有进行中的 PR。 未关闭
harfbuzz/ttf-parser#242 · 3 条评论 · 1 个 reaction · 已指派 2 人 ·
-
help wanted
难度 4/5 3-5 天 新手友好度 45/100
harfbuzz/ttf-parser#241 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 15/100
harfbuzz/ttf-parser#230 · 26 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
harfbuzz/ttf-parser#217 · 6 条评论 ·
查看 harfbuzz/ttf-parser 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
ardia-browser/ardia#5810 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
UIUX の修正未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
aptos-labs/aptos-core#21119 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 8 天内回复