Apply job-local PDF font maps at execution and shipout
This commit is contained in:
1 parent
9527d3bbec
commit
28dfba5a5e
15 files changed
+583
-187
No files matched your search
@@ -37,6 +37,10 @@ impl Files {
|
||||
}
|
||||
c.paths
|
||||
.insert(ResourceKind::Map, vec![SearchPath::directory(map, false)]);
|
||||
c.paths.insert(
|
||||
ResourceKind::Type1,
|
||||
vec![SearchPath::directory(root.join("../../assets/fonts"), false)],
|
||||
);
|
||||
Self {
|
||||
world: FileWorld::new(c).unwrap(),
|
||||
}
|
||||
@@ -49,6 +53,9 @@ impl SourceProvider for Files {
|
||||
fn resource(&mut self, k: ResourceKind, n: &str, f: &str) -> Result<LoadedResource, String> {
|
||||
self.world.read(k, n, Path::new(f))
|
||||
}
|
||||
fn optional_font_map(&mut self, n: &str, f: &str) -> Result<Option<LoadedResource>, String> {
|
||||
self.world.read_optional(ResourceKind::Map, n, Path::new(f))
|
||||
}
|
||||
fn pk_font(&mut self, n: &str, d: u32, f: &str) -> Result<LoadedResource, String> {
|
||||
self.world.read_pk(n, d, Path::new(f))
|
||||
}
|
||||
@@ -312,3 +319,42 @@ fn autoexpanded_bitmap_rejects_at_shipout_before_following_commands() {
|
||||
if matches!(paint.program, NativeFontProgram::Pk(_))
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn font_map_file_binds_new_font_ids_and_locks_used_entries() {
|
||||
let map = directory();
|
||||
fs::write(map.join("pdftex.map"), "% absent row\n").unwrap();
|
||||
fs::write(map.join("outline.map"), "cmr10 CMR10 <cmr10.pfb\n").unwrap();
|
||||
let mut files = Files::with_map(600, &map);
|
||||
let execution = native(
|
||||
r"\pdfpkresolution=600\font\bitmap=cmr10
|
||||
\shipout\hbox{\bitmap AAAA}
|
||||
{\pdfmapfile{+outline.map}}
|
||||
\shipout\hbox{\bitmap AAAB}
|
||||
\font\outline=cmr10 at12pt
|
||||
\shipout\hbox{\outline AAAC}
|
||||
\pdfmapline{-cmr10}
|
||||
\shipout\hbox{\outline AAAD}
|
||||
\end",
|
||||
&mut files,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
messages(&execution),
|
||||
["native PDF warning: fontmap entry for 'cmr10' has been used, replace/delete not allowed"]
|
||||
);
|
||||
let mut pages = execution.shipout_display_lists().unwrap();
|
||||
resolve_native_fonts(&mut pages, &mut files).unwrap();
|
||||
assert_eq!(pages.len(), 4);
|
||||
for (i, page) in pages.iter().enumerate() {
|
||||
use texrra_tex_core::render::DisplayItem;
|
||||
let paint = page.items.iter().find_map(|item| match item {
|
||||
DisplayItem::NativeGlyph { paint, .. } => paint.as_deref(),
|
||||
_ => None,
|
||||
}).unwrap();
|
||||
assert_eq!(matches!(paint.program, NativeFontProgram::Type1(_)), i >= 2);
|
||||
assert_eq!(paint.resources[0].path.file_name().unwrap(),
|
||||
if i >= 2 { "outline.map" } else { "pdftex.map" });
|
||||
}
|
||||
fs::remove_dir_all(map).unwrap();
|
||||
}
|
||||
Reference in new issue
Block a user