Render XeLaTeX shared page resources and scoped graphics
This commit is contained in:
1 parent
e20acc3eb9
commit
009fde04f7
13 files changed
+445
-12
No files matched your search
@@ -783,6 +783,7 @@ fn page_content(
|
||||
let mut tex_text: Option<native_text::NativeText> = None;
|
||||
let mut opentype_text = opentype_fonts::TextState::default();
|
||||
let bp_per_unit = list.units.bp(1);
|
||||
let mut xdv_content_scopes = Vec::new();
|
||||
for (index, item) in list.items.iter().enumerate() {
|
||||
if !matches!(item, DisplayItem::OpenTypeGlyph { .. }) {
|
||||
opentype_text.finish(&mut content);
|
||||
@@ -820,7 +821,11 @@ fn page_content(
|
||||
if let Some((x, y, mode, bytes)) = literal {
|
||||
NativeTextRun::flush(&mut native_text, &mut content);
|
||||
let previous_origin = content.origin;
|
||||
let special_origin = mode.xdv_origin([x, height - y], page_origin);
|
||||
let special_origin = if mode == PdfLiteralMode::XdvCode {
|
||||
Some(xdv_content_scopes.last().map_or(page_origin, |&(_, point)| point))
|
||||
} else {
|
||||
mode.xdv_origin([x, height - y], page_origin)
|
||||
};
|
||||
match mode {
|
||||
PdfLiteralMode::Direct => {
|
||||
native_text::NativeText::break_string(&mut tex_text, &mut content);
|
||||
@@ -831,7 +836,24 @@ fn page_content(
|
||||
content.move_origin([x, height - y], list.units, digits);
|
||||
}
|
||||
}
|
||||
PdfLiteralMode::XdvOrigin | PdfLiteralMode::XdvDirect | PdfLiteralMode::XdvContent => {
|
||||
PdfLiteralMode::XdvBeginContent => {
|
||||
native_text::NativeText::finish(&mut tex_text, &mut content);
|
||||
let point = [x, height - y];
|
||||
xdv_content_scopes.push((previous_origin, point));
|
||||
content.push_str("q\n");
|
||||
content.move_origin(point, list.units, digits);
|
||||
continue;
|
||||
}
|
||||
PdfLiteralMode::XdvEndContent => {
|
||||
native_text::NativeText::finish(&mut tex_text, &mut content);
|
||||
content.push_str("Q\n");
|
||||
if let Some((origin, _)) = xdv_content_scopes.pop() {
|
||||
content.origin = origin;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
PdfLiteralMode::XdvOrigin | PdfLiteralMode::XdvDirect | PdfLiteralMode::XdvContent
|
||||
| PdfLiteralMode::XdvCode => {
|
||||
native_text::NativeText::finish(&mut tex_text, &mut content);
|
||||
if mode == PdfLiteralMode::XdvContent {
|
||||
content.push_str("q\n");
|
||||
@@ -3552,6 +3574,7 @@ fn write_pdf(
|
||||
xdv_objects.write_objects(&references, &mut objects, compression, diagnostics)?;
|
||||
if let Some(xdv) = xdv {
|
||||
xdv.write_page_dictionaries(pages, &references, &mut objects)?;
|
||||
xdv.write_page_resources(&references, &mut objects, diagnostics)?;
|
||||
}
|
||||
for (id, annotation) in xdv_annotations {
|
||||
objects[id - 1] = annotation.pdf(&references, &xdv_names)?;
|
||||
|
||||
Reference in new issue
Block a user