Emit native PDF literals at scan and shipout boundaries

This commit is contained in:
gloamxun committed 2026-11-21 02:03:25 +08:00
1 parent 13ab32247d
commit 432c1d2ba7
21 files changed
+264 -61

No files matched your search

+12 -5
View File
@@ -1,4 +1,5 @@
//! Native pdfTeX text cursor, in original TeX sp, before the page matrix.
use super::PageContent;
use crate::{
execution::FontId,
native_font::NativeFont,
@@ -16,7 +17,7 @@ pub(super) struct NativeText {
impl NativeText {
pub(super) fn glyph(
text: &mut Option<Self>,
out: &mut String,
out: &mut PageContent,
x: i64,
y: i64,
font: &NativeFont,
@@ -84,7 +85,7 @@ impl NativeText {
shift = 0;
}
if !state.opened {
out.push('[');
out.push(b'[');
state.opened = true;
}
if shift != 0 {
@@ -109,13 +110,19 @@ impl NativeText {
crate::pdf_device::magnify(advance, 1000 + font.expansion)
};
}
fn close_string(&mut self, out: &mut String) {
fn close_string(&mut self, out: &mut PageContent) {
if self.opened {
out.push_str("] TJ\n");
self.opened = false;
}
}
pub(super) fn finish(text: &mut Option<Self>, out: &mut String) {
pub(super) fn break_string(text: &mut Option<Self>, out: &mut PageContent) {
if let Some(text) = text {
text.close_string(out);
}
}
pub(super) fn finish(text: &mut Option<Self>, out: &mut PageContent) {
if let Some(mut text) = text.take() {
text.close_string(out);
if text.expansion != 0 {
@@ -127,7 +134,7 @@ impl NativeText {
}
pub(super) fn rule(
out: &mut String,
out: &mut PageContent,
x: i64,
top: i64,
w: i64,