Write physical Type 1 subsets for imported PDF fonts

This commit is contained in:
gloamxun committed 2026-11-26 16:03:43 +08:00
1 parent a90d53c992
commit 5edd4ae4ec
8 files changed
+384 -22

No files matched your search

@@ -16,6 +16,8 @@ pub(super) struct MapEntry {
pub from: PathBuf,
pub version: Option<ResourceVersion>,
file: Option<String>,
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
subset: bool,
pub encoding: Option<String>,
postscript_name: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -91,6 +93,7 @@ fn parse_map_line(
from: from.to_path_buf(),
version: version.cloned(),
file: None,
subset: false,
encoding: None,
postscript_name: false,
ps_name: None,
@@ -124,6 +127,7 @@ fn parse_map_line(
entry.encoding = Some(path.to_owned());
} else if !path.is_empty() {
entry.file = Some(path.to_owned());
entry.subset = !value.starts_with("<<");
}
} else if index == 0 && !value.as_bytes()[0].is_ascii_digit() {
entry.postscript_name = true;
@@ -264,7 +268,7 @@ impl JobFontMap {
pub(super) fn imported_type1_program(
&mut self, name: &str, from: &Path, files: &mut impl SourceProvider,
) -> Result<Option<(crate::type1::Type1Font, i32)>, String> {
) -> Result<Option<(crate::type1::Type1Font, i32, bool)>, String> {
let (name, transform) = imported_postscript_name(name);
if self.bindings.is_none() {
self.initialize(true, from, files)?;
@@ -282,7 +286,7 @@ impl JobFontMap {
self.used_names.insert(tfm.clone());
}
self.used_postscript.insert(key);
Ok(Some((font, entry.descriptor_flags.unwrap_or(4))))
Ok(Some((font, entry.descriptor_flags.unwrap_or(4), entry.subset)))
}
pub(super) fn command(
@@ -471,5 +475,6 @@ pub(super) fn dedicated_space_map(font: &NativeFont) -> MapEntry {
ps_name: None,
descriptor_flags: None,
transform: Type1Transform::default(),
subset: false,
}
}