Share physical Type 1 fonts across PDF page resources
This commit is contained in:
1 parent
5edd4ae4ec
commit
38c567623a
11 files changed
+385
-140
No files matched your search
@@ -3,6 +3,7 @@ mod bmp;
|
||||
mod jpeg;
|
||||
mod icc;
|
||||
mod imported_fonts;
|
||||
pub(crate) use imported_fonts::ImportedType1Use;
|
||||
mod png;
|
||||
use crate::{
|
||||
pdf_device::Affine,
|
||||
@@ -330,6 +331,7 @@ enum Part {
|
||||
Png(png::SampledImage),
|
||||
Bmp(png::SampledImage),
|
||||
XdvCmykDecode,
|
||||
MappedType1(Arc<ImportedType1Use>),
|
||||
}
|
||||
|
||||
pub(crate) fn real(value: f64) -> String {
|
||||
@@ -724,6 +726,7 @@ impl PdfImage {
|
||||
attributes: &[u8],
|
||||
compression: u8,
|
||||
pdf_version: (i32, i32),
|
||||
fonts: &crate::pdf::type1_fonts::References<'_>,
|
||||
) -> usize {
|
||||
if let Some(samples) = self.sampled_image() {
|
||||
return samples.append(pdf, attributes, compression, pdf_version);
|
||||
@@ -742,6 +745,12 @@ impl PdfImage {
|
||||
match part {
|
||||
Part::Bytes(bytes) | Part::Jpeg { bytes, .. } => body.extend_from_slice(bytes),
|
||||
Part::Ref(id) => write!(body, "{} 0 R", base + id).unwrap(),
|
||||
Part::MappedType1(font) => {
|
||||
let reference = &fonts[&font.mapped.key()];
|
||||
body.extend_from_slice(b" /BaseFont ");
|
||||
body.extend(pdf_name(reference.name.as_bytes()));
|
||||
write!(body, " /FontDescriptor {} 0 R", reference.object).unwrap();
|
||||
}
|
||||
Part::Png(_) | Part::Bmp(_) => unreachable!("sampled image owns its objects"),
|
||||
Part::XdvCmykDecode => {
|
||||
if !attributes
|
||||
|
||||
Reference in new issue
Block a user