Use physical Type 1 glyph widths in XeTeX PDF output

This commit is contained in:
gloamxun committed 2026-11-28 06:23:12 +08:00
1 parent 885911485e
commit b22e127e93
11 files changed
+210 -33

No files matched your search

+14 -7
View File
@@ -1854,17 +1854,24 @@ fn write_native_font(
let last = *used.keys().next_back().unwrap();
let widths = (first..=last)
.map(|slot| {
format!(
"{:.1}",
let width = if paint.xdv_descriptor.is_some() {
if used.contains_key(&slot) {
*paint.xdv_widths.get(&slot).ok_or_else(|| format!(
"native XeTeX font {} has no PDF width for slot {slot}", face.name,
))?
} else {
0
}
} else {
native_font_units(
m.width(char::from(slot)),
native_pdf_font_size(m.size_sp()),
10_000
) as f64
/ 10.0
)
10_000,
)
};
Ok(format!("{:.1}", width as f64 / 10.0))
})
.collect::<Vec<_>>()
.collect::<Result<Vec<_>, String>>()?
.join(" ");
let (subtype, descriptor, name, widths, encoding, has_glyph_unicode) = match &paint.program {
NativeFontProgram::Type1(font) => {