Reuse verified Type 1 glyph and PDF subset output across edits
This commit is contained in:
1 parent
6939ff71ff
commit
11c8ad1eaa
12 files changed
+236
-11
No files matched your search
@@ -19,11 +19,13 @@ mod device_type1;
|
||||
mod map;
|
||||
mod sfd;
|
||||
mod truetype;
|
||||
mod type1_cache;
|
||||
mod virtual_paint;
|
||||
pub use cff::OpenTypeCffProgram;
|
||||
pub use composite_type1::CompositeType1Program;
|
||||
pub use device_type1::DeviceType1Program;
|
||||
pub use truetype::TrueTypeProgram;
|
||||
pub use type1_cache::Type1FontWork;
|
||||
pub(crate) use truetype::cid_width;
|
||||
pub use map::PdfFontBindings;
|
||||
pub(crate) use map::XdvFontMatrix;
|
||||
@@ -305,15 +307,17 @@ pub(crate) fn verify_resource(
|
||||
const MAX_TYPE1_PROGRAMS: usize = 16;
|
||||
const MAX_CACHED_TYPE1_BYTES: usize = 256 * 1024;
|
||||
|
||||
/// Decoded Type 1 programs shared across revisions in one compiler.
|
||||
/// Verified Type 1 programs and derived device data shared across revisions.
|
||||
#[derive(Default)]
|
||||
pub struct NativeFontCache {
|
||||
type1: Mutex<VecDeque<((ResourceVersion, Type1Transform), Arc<DecodedType1>)>>,
|
||||
type1_output: type1_cache::Type1OutputCache,
|
||||
}
|
||||
|
||||
struct DecodedType1 {
|
||||
program: Arc<Type1Font>,
|
||||
outlines: Type1Outlines,
|
||||
glyphs: Mutex<type1_cache::GlyphMeasurements>,
|
||||
bbox: [i32; 4],
|
||||
stem_v: i32,
|
||||
xdv_descriptor: OnceLock<Result<XdvDescriptor, String>>,
|
||||
@@ -334,6 +338,7 @@ impl DecodedType1 {
|
||||
Ok(Self {
|
||||
program: Arc::new(program),
|
||||
outlines,
|
||||
glyphs: Mutex::default(),
|
||||
bbox,
|
||||
stem_v,
|
||||
xdv_descriptor: OnceLock::new(),
|
||||
@@ -758,7 +763,7 @@ fn resolve_physical_fonts(
|
||||
font.name
|
||||
));
|
||||
}
|
||||
let (path, width) = outlines.glyph_path_and_width(name)?;
|
||||
let (path, width) = font_cache.type1_glyph(decoded, name)?;
|
||||
paint.glyph_paths.insert(slot, path);
|
||||
if paint.xdv_descriptor.is_some() {
|
||||
paint.xdv_widths.insert(slot, width);
|
||||
|
||||
Reference in new issue
Block a user