Expose active insertion height to pdfTeX macros
This commit is contained in:
1 parent
2fa11fb971
commit
7707cd9b09
7 files changed
+70
-4
No files matched your search
@@ -1033,6 +1033,7 @@ impl Executor {
|
||||
}
|
||||
}
|
||||
Pdfximagebbox => self.expand_pdf_image_bbox(token, files)?,
|
||||
Pdfinsertht => self.expand_pdf_insertion_height(token, files)?,
|
||||
Pdfstrcmp => {
|
||||
let left = self.scan_expanded_group(files)?;
|
||||
let left = self.token_list_text(&left);
|
||||
|
||||
@@ -77,6 +77,21 @@ impl Executor {
|
||||
.dimension(p.page_dimension().unwrap());
|
||||
i32::try_from(value).map_err(|_| self.error("native page dimension overflow", self.current))
|
||||
}
|
||||
pub(super) fn expand_pdf_insertion_height(
|
||||
&mut self, token: &Token, files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
let index = self.register_index(files)?;
|
||||
self.reads.insert(Dependency::PageState);
|
||||
let height = u8::try_from(index).ok().and_then(|class| {
|
||||
self.native_page.as_ref()?.insertions.height(class)
|
||||
});
|
||||
let value = height.map_or_else(
|
||||
|| "0pt".to_owned(),
|
||||
|size| format!("{}pt", super::super::registers::print_scaled_wide(size)),
|
||||
);
|
||||
self.print_tokens(&value, token)
|
||||
}
|
||||
|
||||
pub(super) fn request_page(&mut self) {
|
||||
if self.outer_vertical() {
|
||||
if let Some(page) = self.native_page.as_mut() {
|
||||
|
||||
@@ -16,9 +16,9 @@ use std::{
|
||||
sync::{Arc, Mutex, OnceLock, Weak},
|
||||
};
|
||||
|
||||
const SCHEMA: u32 = 106;
|
||||
const COMPATIBLE_SCHEMAS: [u32; 72] = [
|
||||
27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, SCHEMA,
|
||||
const SCHEMA: u32 = 107;
|
||||
const COMPATIBLE_SCHEMAS: [u32; 73] = [
|
||||
27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, SCHEMA,
|
||||
];
|
||||
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
@@ -232,6 +232,9 @@ impl FormatImage {
|
||||
if image.schema < 106 {
|
||||
image.state.install_pdf_image_query_command();
|
||||
}
|
||||
if image.schema < 107 {
|
||||
image.state.install_pdf_insertion_query_command();
|
||||
}
|
||||
let pdf_objects = image.state.pdf_objects.as_deref();
|
||||
let mut numbered_images = 0;
|
||||
for (index, saved) in image.pdf_images.iter().enumerate() {
|
||||
|
||||
@@ -52,6 +52,10 @@ fn scale(size: i64, factor: i64) -> i64 {
|
||||
}
|
||||
|
||||
impl PageInsertions {
|
||||
pub(super) fn height(&self, class: u8) -> Option<i64> {
|
||||
self.classes.get(&class).map(|entry| entry.size)
|
||||
}
|
||||
|
||||
pub(super) fn activity<'a>(
|
||||
&'a self,
|
||||
state: &'a State,
|
||||
|
||||
@@ -103,6 +103,7 @@ pub enum Primitive {
|
||||
Pdfrefximage,
|
||||
Pdflastximage,
|
||||
Pdfximagebbox,
|
||||
Pdfinsertht,
|
||||
Pdflastximagepages,
|
||||
Pdflastximagecolordepth,
|
||||
Jobname,
|
||||
@@ -533,6 +534,7 @@ impl Primitive {
|
||||
| XeTeXselectorname
|
||||
| Pdfstrcmp
|
||||
| Pdfximagebbox
|
||||
| Pdfinsertht
|
||||
| Pdfmatch
|
||||
| Pdflastmatch
|
||||
| Pdfuniformdeviate
|
||||
@@ -952,6 +954,7 @@ const PDFTEX_ONLY_PRIMITIVES: &[(&str, Primitive)] = {
|
||||
("pdfrefximage", Pdfrefximage),
|
||||
("pdflastximage", Pdflastximage),
|
||||
("pdfximagebbox", Pdfximagebbox),
|
||||
("pdfinsertht", Pdfinsertht),
|
||||
("pdflastximagepages", Pdflastximagepages),
|
||||
("pdflastximagecolordepth", Pdflastximagecolordepth),
|
||||
("pdfcreationdate", Pdfcreationdate),
|
||||
@@ -2015,6 +2018,11 @@ impl State {
|
||||
self.update_profile_command("pdfximagebbox", Meaning::Primitive(Primitive::Pdfximagebbox), enabled);
|
||||
}
|
||||
|
||||
pub(super) fn install_pdf_insertion_query_command(&mut self) {
|
||||
let enabled = self.input_profile != super::InputProfile::XeTeX;
|
||||
self.update_profile_command("pdfinsertht", Meaning::Primitive(Primitive::Pdfinsertht), enabled);
|
||||
}
|
||||
|
||||
fn install_pdftex_primitives(&mut self) {
|
||||
let enabled = self.input_profile != super::InputProfile::XeTeX;
|
||||
for &(name, primitive) in PDFTEX_ONLY_PRIMITIVES {
|
||||
|
||||
Reference in new issue
Block a user