Implement pdfTeX random primitives with checkpointed state

This commit is contained in:
gloamxun committed 2026-11-21 01:10:55 +08:00
1 parent a958954308
commit 5c2ba9fad0
13 files changed
+230 -8

No files matched your search

@@ -26,6 +26,8 @@ pub struct JobTime {
pdf_clock: Option<(u8, i16)>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pdf_calendar: Option<(i32, i32, i32, i32)>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(super) random_seed: Option<i32>,
}
impl JobTime {
pub fn new(year: i32, month: i32, day: i32, minutes: i32) -> Result<Self, &'static str> {
@@ -47,8 +49,15 @@ impl JobTime {
minutes,
pdf_clock: None,
pdf_calendar: None,
random_seed: None,
})
}
/// Fix the job's initial pdfTeX random sequence across equivalent runs.
pub fn with_random_seed(mut self, seed: i32) -> Self {
self.random_seed = Some(seed.saturating_abs());
self
}
/// Add the seconds and UTC offset supplied by the job host.
pub fn with_pdf_clock(
mut self,