Apply job-local PDF font maps at execution and shipout

This commit is contained in:
gloamxun committed 2026-11-21 09:53:31 +08:00
1 parent 9527d3bbec
commit 28dfba5a5e
15 files changed
+583 -187

No files matched your search

@@ -12,6 +12,7 @@ impl Executor {
use Primitive::*;
match primitive {
Pdfglyphtounicode => self.glyph_to_unicode(files)?,
Pdfmapfile | Pdfmapline => self.pdf_font_map_command(primitive, token.span, files)?,
Pdffontattr | Pdfnobuiltintounicode => {
self.pdf_font_settings(primitive, files)?;
}
@@ -83,6 +84,30 @@ impl Executor {
}
Ok(())
}
fn pdf_font_map_command(
&mut self, primitive: Primitive, span: Span, files: &mut impl SourceProvider,
) -> Result<(), Error> {
if self.read_parameter(Parameter::Pdfoutput).width() <= 0 {
return self.fail("PDF font map commands are not allowed in DVI mode");
}
let tokens = self.scan_expanded_group(files)?;
let bytes = self.pdf_token_bytes(&tokens)?;
let suppress_duplicates = self.read_parameter(Parameter::Pdfsuppresswarningdupmap).width() > 0;
let from = self.source_name(span);
self.reads.insert(Dependency::FontResources);
let warnings = Arc::make_mut(&mut self.pdf_virtual_fonts)
.update_font_map(&bytes, primitive == Primitive::Pdfmapfile, std::path::Path::new(&from),
suppress_duplicates, files)
.map_err(|error| self.error(error, span))?;
for warning in warnings {
let text = format!("native PDF warning: {warning}");
files.observe_diagnostic(WriteDestination::TerminalAndLog, &format!("{text}\n"))
.map_err(|e| self.error(e, span))?;
self.events.push(Event::Message { text, span });
}
Ok(())
}
pub(super) fn glyph_to_unicode(
&mut self,
files: &mut impl SourceProvider,