GPOS PairPosFormat1: device/VariationIndex offsets in PairValueRecords are resolved from the wrong base, so they are always dropped

Đang mở
#245 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@mamicicekel đang làm issue này rồi.

Từ ngày 23/11/2026.

  • #246 của @mamicicekel — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
67/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
798
Fork
96
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của harfbuzz/ttf-parser

Tất cả issue của harfbuzz/ttf-parser

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.