Rebind native format TFM resources after project relocation
This commit is contained in:
1 parent
1ad9c4db82
commit
65204a7dae
9 files changed
+304
-35
No files matched your search
@@ -1716,12 +1716,39 @@ impl State {
|
||||
})
|
||||
}
|
||||
|
||||
fn visit_format_fonts_mut(
|
||||
&mut self,
|
||||
mut visit: impl FnMut(&mut std::sync::Arc<crate::native_font::NativeFont>),
|
||||
) {
|
||||
for b in self.boxes.values_mut() {
|
||||
b.visit_format_fonts_mut(&mut visit);
|
||||
}
|
||||
for form in self.pdf_forms.values_mut() {
|
||||
if let crate::pdf_device::forms::FormContents::Pending(body) = &mut form.contents {
|
||||
std::sync::Arc::make_mut(body).box_node.visit_format_fonts_mut(&mut visit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn rebind_format_font_resources(
|
||||
&mut self,
|
||||
bindings: &BTreeMap<std::path::PathBuf, std::path::PathBuf>,
|
||||
) {
|
||||
if self.fonts.rebind_format_resources(bindings) {
|
||||
self.visit_format_fonts_mut(|font| {
|
||||
crate::native_font::NativeFont::rebind_resource_path(font, bindings);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn restore_legacy_format_fonts(&mut self) -> Result<(), String> {
|
||||
let replacements = self.fonts.restore_legacy_synthesized_fonts()?;
|
||||
if !replacements.is_empty() {
|
||||
for b in self.boxes.values_mut() {
|
||||
b.rebind_legacy_expansion_fonts(&replacements);
|
||||
}
|
||||
self.visit_format_fonts_mut(|font| {
|
||||
if let Some(logical) = replacements.get(&(font.id, font.expansion)) {
|
||||
*font = logical.clone();
|
||||
}
|
||||
});
|
||||
}
|
||||
self.fonts.reset_format_font_state();
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user