Execute positioned TeX specials through native PDF devices
This commit is contained in:
1 parent
05e633bb14
commit
ce8a780031
21 files changed
+519
-29
No files matched your search
@@ -278,15 +278,23 @@ impl Executor {
|
||||
}
|
||||
let magnification = self.prepare_magnification()?;
|
||||
let pdf = self.pdf_page_data(files)?;
|
||||
let unicode_pages = self.state.input_profile() == InputProfile::UnicodeScalar;
|
||||
// The XDV driver uses a physical sheet and origin, then applies
|
||||
// magnification to the DVI movements relative to that origin.
|
||||
let origin = |value| {
|
||||
if unicode_pages {
|
||||
crate::pdf_device::unmagnify(value, magnification)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
};
|
||||
let horizontal_origin =
|
||||
i64::from(self.read_parameter(Parameter::Pdfhorigin).width()) + h_offset;
|
||||
origin(i64::from(self.read_parameter(Parameter::Pdfhorigin).width())) + h_offset;
|
||||
let vertical_origin =
|
||||
i64::from(self.read_parameter(Parameter::Pdfvorigin).width()) + v_offset;
|
||||
origin(i64::from(self.read_parameter(Parameter::Pdfvorigin).width())) + v_offset;
|
||||
let mut page_width = i64::from(self.read_parameter(Parameter::Pdfpagewidth).width());
|
||||
let requested_page_height = i64::from(self.read_parameter(Parameter::Pdfpageheight).width());
|
||||
let unicode_pages = self.state.input_profile() == super::super::InputProfile::UnicodeScalar;
|
||||
// The XeTeX PDF device uses the default letter canvas unless a page size was supplied.
|
||||
let default_canvas = |bp: i64| bp * 803 * 65536 / 800;
|
||||
let default_canvas = |bp: i64| origin(bp * 803 * 65536 / 800);
|
||||
if page_width == 0 {
|
||||
page_width = if unicode_pages { default_canvas(612) } else { b.width + 2 * horizontal_origin };
|
||||
}
|
||||
@@ -335,6 +343,7 @@ impl Executor {
|
||||
pdf_color_start,
|
||||
pdf_color_steps: Vec::new(),
|
||||
pdf_graphics_steps: Vec::new(),
|
||||
specials: Vec::new(),
|
||||
pdf_text_spaces: None,
|
||||
pdf_resource_entries,
|
||||
pdf_page_attributes,
|
||||
@@ -394,6 +403,7 @@ impl Executor {
|
||||
&& matches!(
|
||||
output.operation,
|
||||
OutputOperation::Write { .. } | OutputOperation::PdfLiteral { shipout: true, .. }
|
||||
| OutputOperation::Special { shipout: true, .. }
|
||||
)
|
||||
{
|
||||
shipout.pdf_font_bindings = self.pdf_virtual_fonts.captured_font_bindings();
|
||||
@@ -421,16 +431,27 @@ impl Executor {
|
||||
return self.fail("cannot ship a PDF color operation to DVI");
|
||||
}
|
||||
shipout.pdf_color_steps.push(self.ship_pdf_color(*stack, action, output.span, files)?);
|
||||
} else if matches!(output.operation, OutputOperation::Special { .. }) {
|
||||
let special = self.resolve_special(
|
||||
output, position.expect("special needs a shipout position"), files,
|
||||
)?;
|
||||
let graphics = if let Some(pdf) = &device.pdf {
|
||||
self.render_special(&special, pdf.driver, files)?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
shipout.specials.push(special);
|
||||
shipout.pdf_graphics_steps.push(graphics);
|
||||
} else if output.is_pdf_graphics() {
|
||||
if device.pdf.is_none() {
|
||||
return self.fail("cannot ship a PDF graphics operation to DVI");
|
||||
}
|
||||
shipout.pdf_graphics_steps.push(self.ship_pdf_graphics(
|
||||
shipout.pdf_graphics_steps.push(Some(self.ship_pdf_graphics(
|
||||
output,
|
||||
position.expect("PDF graphics need a shipout position"),
|
||||
&mut graphics_stack,
|
||||
files,
|
||||
)?);
|
||||
)?));
|
||||
} else if let OutputOperation::PdfSavePosition = output.operation {
|
||||
self.current = output.span;
|
||||
self.tick()?;
|
||||
|
||||
Reference in new issue
Block a user