Resolve imported PDF Type 1 device fonts in native previews
This commit is contained in:
1 parent
c0970bdbf6
commit
b640b26eff
12 files changed
+586
-106
No files matched your search
@@ -304,6 +304,17 @@ impl DecodedType1 {
|
||||
}
|
||||
|
||||
impl NativeFontCache {
|
||||
/// Resolve a PDF device font using the same exact program identity as native text.
|
||||
pub fn pdf_device_type1(
|
||||
&self,
|
||||
files: &mut impl crate::execution::SourceProvider,
|
||||
name: &str,
|
||||
from: &str,
|
||||
) -> Result<Option<Arc<Type1Font>>, String> {
|
||||
Ok(device_type1::find_program(files, self, name, None, from)?
|
||||
.map(|(_, decoded)| decoded.program.clone()))
|
||||
}
|
||||
|
||||
// The caller reads the actual resource and verifies its bytes on this
|
||||
// revision before asking for the decoded representation.
|
||||
fn type1(&self, resource: &LoadedResource, transform: Type1Transform) -> Result<Arc<DecodedType1>, String> {
|
||||
@@ -429,7 +440,8 @@ fn resolve_physical_fonts(
|
||||
let Some((first, _, _)) = used.values().next() else {
|
||||
return Ok(());
|
||||
};
|
||||
let captured = pages.iter().rev().find_map(|page| page.pdf_font_bindings.as_deref());
|
||||
let captured_bindings = pages.iter().rev().filter_map(|page| page.pdf_font_bindings.as_deref());
|
||||
let captured = captured_bindings.clone().next();
|
||||
let default_map = if captured.is_none() {
|
||||
load_map(files, "pdftex.map", &first.resource.version.path)?
|
||||
} else {
|
||||
@@ -448,8 +460,11 @@ fn resolve_physical_fonts(
|
||||
for (id, (font, slots, expanded)) in used {
|
||||
let entry = if font.pdf_space_font && font.name == "pdftexspace" {
|
||||
Some(Arc::new(dedicated_space_map(&font)))
|
||||
} else if let Some(bindings) = captured {
|
||||
bindings.font(&font)?
|
||||
} else if captured.is_some() {
|
||||
// Pending Form lists may precede the last real page in execution
|
||||
// order, even when the host appends them for physical font painting.
|
||||
captured_bindings.clone().find_map(|bindings| bindings.font(&font).ok())
|
||||
.ok_or_else(|| format!("PDF font {} has no captured map binding", font.name))?
|
||||
} else if let Some(map) = &default_map {
|
||||
find_map_entry(map, &font.name, files, &mut subfonts)?.map(Arc::new)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user