Reload letterspaced font metrics independently of generated packets
This commit is contained in:
1 parent
65204a7dae
commit
aa780a800b
6 files changed
+154
-3
No files matched your search
@@ -1046,6 +1046,14 @@ impl FontCatalog {
|
||||
relocated
|
||||
}
|
||||
|
||||
pub(super) fn discard_letterspace_programs(&mut self) -> bool {
|
||||
let mut discarded = false;
|
||||
for font in self.fonts.iter_mut().filter_map(|font| font.glyph_font.as_mut()) {
|
||||
discarded |= NativeFont::discard_letterspace_program(font);
|
||||
}
|
||||
discarded
|
||||
}
|
||||
|
||||
pub(super) fn reset_format_font_state(&mut self) {
|
||||
for font in &mut self.fonts {
|
||||
font.expansion_origin = None;
|
||||
|
||||
@@ -16,9 +16,9 @@ use std::{
|
||||
sync::{Arc, Mutex, OnceLock, Weak},
|
||||
};
|
||||
|
||||
const SCHEMA: u32 = 94;
|
||||
const COMPATIBLE_SCHEMAS: [u32; 60] = [
|
||||
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, SCHEMA,
|
||||
const SCHEMA: u32 = 95;
|
||||
const COMPATIBLE_SCHEMAS: [u32; 61] = [
|
||||
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, SCHEMA,
|
||||
];
|
||||
const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
@@ -253,6 +253,9 @@ impl FormatImage {
|
||||
{
|
||||
return Err("invalid native format PDF Form registry".into());
|
||||
}
|
||||
if image.schema < 95 {
|
||||
image.state.discard_format_letterspace_programs();
|
||||
}
|
||||
image.schema = SCHEMA;
|
||||
Ok(image)
|
||||
}
|
||||
|
||||
@@ -1683,6 +1683,7 @@ impl State {
|
||||
self.pdf_info.clear();
|
||||
self.pdf_pages_attributes.clear();
|
||||
self.fonts.reset_format_font_state();
|
||||
self.discard_format_letterspace_programs();
|
||||
self
|
||||
}
|
||||
pub(super) fn rebind_format_images(
|
||||
@@ -1730,6 +1731,16 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn discard_format_letterspace_programs(&mut self) {
|
||||
// The format retains the widened TeX metrics. The generated virtual
|
||||
// packets belong to the job that defined the letter-spaced font.
|
||||
if self.fonts.discard_letterspace_programs() {
|
||||
self.visit_format_fonts_mut(|font| {
|
||||
crate::native_font::NativeFont::discard_letterspace_program(font);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn rebind_format_font_resources(
|
||||
&mut self,
|
||||
bindings: &BTreeMap<std::path::PathBuf, std::path::PathBuf>,
|
||||
|
||||
@@ -114,6 +114,14 @@ pub(crate) fn unexpanded(amount: &i32) -> bool {
|
||||
}
|
||||
|
||||
impl NativeFont {
|
||||
pub(crate) fn discard_letterspace_program(font: &mut Arc<Self>) -> bool {
|
||||
if font.letter_spacing.is_none() {
|
||||
return false;
|
||||
}
|
||||
Arc::make_mut(font).letter_spacing = None;
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn rebind_resource_path(
|
||||
font: &mut Arc<Self>,
|
||||
bindings: &BTreeMap<std::path::PathBuf, std::path::PathBuf>,
|
||||
|
||||
Reference in new issue
Block a user