Panic: "remapper was overflowed" when composite glyphs reach all 65,536 glyph IDs
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 56/100
Hướng nghiên cứu
Start by reading subsetter-0.2.6/src/remapper.rs around the overflowing u16 count and trace how glyf::closure remaps composite components. The reproduction in the issue demonstrates the failure when all 65,536 glyph IDs are reached; use it to check a fix. Done means subset returns an error or handles out-of-range component IDs without panicking.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
subset panics on a TrueType font whose glyph closure reaches all 65,536 glyph IDs, in any build:
thread 'main' panicked at subsetter-0.2.6/src/remapper.rs:91:18:
remapper was overflowed
glyf::closure remaps every glyph it reaches through composite components, and Remapper::remap counts them in a u16 with .expect("remapper was overflowed"). Components may name glyph IDs past maxp's glyph count, which Table::glyph_data still reads where loca gives them an entry, so a composite glyph (or several) can reach every ID from 0 to 65535: the 65,536th glyph remapped panics. This happens with 0.2.6 and with main (b0adcc1). (#34 is the same expect reached through the Font DICT remapper of CFF fonts.)
To reproduce with subsetter 0.2.6 (default-features = false). The font is built for this report: three tables, glyf, head and loca, where .notdef is a composite of the empty glyphs 1 to 65535.
fn main() {
// A TrueType font of three tables, built for this report: glyph 0 is a composite of
// the empty glyphs 1 to 65535, which `loca` gives entries.
let mut glyf = vec![0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0]; // numberOfContours -1, bbox
for glyph in 1..=u16::MAX {
let flags: u16 = if glyph == u16::MAX { 0x0002 } else { 0x0022 }; // MORE_COMPONENTS
glyf.extend(flags.to_be_bytes());
glyf.extend(glyph.to_be_bytes());
glyf.extend([0, 0]); // byte arguments
}
let mut loca = Vec::new();
loca.extend(0u32.to_be_bytes());
for _ in 0..=u16::MAX {
loca.extend((glyf.len() as u32).to_be_bytes()); // glyphs 1.. are empty
}
let mut head = vec![0; 54];
head[51] = 1; // indexToLocFormat: long
let tables: [(&[u8; 4], Vec<u8>); 3] = [(b"glyf", glyf), (b"head", head), (b"loca", loca)];
let mut font = vec![0, 1, 0, 0, 0, 3, 0, 32, 0, 1, 0, 16];
let mut offset = 12 + 16 * tables.len();
for (tag, table) in &tables {
font.extend(*tag);
font.extend([0; 4]); // checksum, not checked
font.extend((offset as u32).to_be_bytes());
font.extend((table.len() as u32).to_be_bytes());
offset += table.len().next_multiple_of(4);
}
for (_, table) in &tables {
font.extend(table);
font.resize(font.len().next_multiple_of(4), 0);
}
let remapper = subsetter::GlyphRemapper::new();
println!("{:?}", subsetter::subset(&font, 0, &remapper).map(|font| font.len()));
}
cargo run and cargo run --release both panic as above.
It was found by the independent review of a officewright PR that checks glyphs for subsetting; until it is fixed, our call to subset refuses such a subset before the subsetter runs.
A possible fix: return an error from closure (for example MalformedFont) once the remapper holds 65,536 glyphs, or skip components that are not below maxp's glyph count.
- Ngôn ngữ chính
- Rust
- Star
- 61
- Fork
- 16
- 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
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của typst/subsetter
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
head table bounding box is not recalculated for variable font instancesCó thể đã có người làm @khaledhosny đã nhận 16 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
Tất cả issue của typst/subsetter
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Input: placeholder drawn in the text colour when the empty Input is focused but not yet editedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pierreaubert/gpui-toolkit#114 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BibLaTeX `type` keys like `phdthesis`, `mathesis`, `techreport` are printed raw instead of localizedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
remove the use of `forget`Đang mởgood first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
compiler
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
HerringtonDarkholme/hd-lang#1853 ·
Maintainer thường phản hồi trong vòng 1 ngày