Resolve pdfTeX SFD subfonts against actual TrueType cmaps

This commit is contained in:
gloamxun committed 2026-11-28 03:04:48 +08:00
1 parent fd5ab59f42
commit 868814288c
10 files changed
+481 -43

No files matched your search

@@ -17,17 +17,25 @@ pub(super) fn write(
) -> Result<(usize, String), String> {
let mut slots: BTreeSet<_> = used.collect();
let name = if paint.subset {
let names = slots
.iter()
.map(|&slot| &paint.encoding[usize::from(slot)])
.filter(|name| *name != ".notdef")
.cloned()
.collect();
let names = if let Some(codes) = &program.subfont_codes {
slots
.iter()
.filter_map(|&slot| codes[usize::from(slot)])
.map(|code| format!("/c{code:04X}"))
.collect()
} else {
slots
.iter()
.map(|&slot| &paint.encoding[usize::from(slot)])
.filter(|name| *name != ".notdef")
.cloned()
.collect()
};
let tag = (0..100)
.map(|salt| subset_tag(&program.name, &names, salt))
.find(|tag| subset_tags.insert(tag.clone()))
.ok_or("TrueType subset name collision limit exceeded")?;
if paint.encoding[97] == "a" {
if program.subfont_codes.is_none() && paint.encoding[97] == "a" {
// Match pdfTeX's additional glyph for older PDF readers.
slots.insert(b'a');
}