Share XeTeX PDF font resources across compatible instances
This commit is contained in:
1 parent
a864c6c5ca
commit
4ae4275cf3
5 files changed
+179
-18
No files matched your search
@@ -6,7 +6,7 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::io::Write as _;
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
use flate2::Compression;
|
||||
use flate2::write::ZlibEncoder;
|
||||
@@ -732,7 +732,7 @@ fn page_content(
|
||||
cm_codes: &[Option<&BTreeMap<char, u8>>],
|
||||
fallback_ids: &[usize; FACE_COUNT],
|
||||
origin: PageOrigin,
|
||||
opentype: &BTreeMap<crate::execution::FontId, opentype_fonts::EmbeddedFont>,
|
||||
opentype: &BTreeMap<crate::execution::FontId, Arc<opentype_fonts::EmbeddedFont>>,
|
||||
font_opacities: &BTreeMap<u8, String>,
|
||||
) -> Vec<u8> {
|
||||
let digits = list.pdf.as_ref().map_or(3, |p| p.file.decimal_digits);
|
||||
@@ -2883,11 +2883,14 @@ fn write_pdf(
|
||||
}
|
||||
if !opentype.is_empty() {
|
||||
let open_fonts: BTreeSet<_> = list.items.iter().filter_map(|item| match item {
|
||||
DisplayItem::OpenTypeGlyph { font, .. } => Some(font.id),
|
||||
DisplayItem::OpenTypeGlyph { font, .. } => {
|
||||
let resource = &opentype[&font.id];
|
||||
Some((resource.resource, resource.object))
|
||||
}
|
||||
_ => None,
|
||||
}).collect();
|
||||
for id in open_fonts {
|
||||
fonts.push_str(&format!(" /U{} {} 0 R", id.index(), opentype[&id].object));
|
||||
for (id, object) in open_fonts {
|
||||
fonts.push_str(&format!(" /U{} {object} 0 R", id.index()));
|
||||
}
|
||||
}
|
||||
fonts
|
||||
|
||||
Reference in new issue
Block a user