Render legacy XeLaTeX composite Type 1 fonts
This commit is contained in:
1 parent
ff52a9f66b
commit
e7ab132520
11 files changed
+497
-116
No files matched your search
@@ -14,12 +14,14 @@ use std::{
|
||||
};
|
||||
mod cff;
|
||||
mod composite;
|
||||
mod composite_type1;
|
||||
mod device_type1;
|
||||
mod map;
|
||||
mod sfd;
|
||||
mod truetype;
|
||||
mod virtual_paint;
|
||||
pub use cff::OpenTypeCffProgram;
|
||||
pub use composite_type1::CompositeType1Program;
|
||||
pub use device_type1::DeviceType1Program;
|
||||
pub use truetype::TrueTypeProgram;
|
||||
pub(crate) use truetype::cid_width;
|
||||
@@ -90,6 +92,7 @@ impl NativeFontPaint {
|
||||
match &self.program {
|
||||
NativeFontProgram::TrueType(program) => program.composite.as_ref(),
|
||||
NativeFontProgram::OpenTypeCff(program) => program.composite.as_ref(),
|
||||
NativeFontProgram::CompositeType1(program) => Some(&program.mapping),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -118,7 +121,8 @@ impl NativeFontPaint {
|
||||
NativeFontProgram::Type1(font) => self.resources.get(self.program_index.unwrap_or(1))
|
||||
.map(|version| (version, font.transform)),
|
||||
NativeFontProgram::Pk(_) | NativeFontProgram::TrueType(_)
|
||||
| NativeFontProgram::OpenTypeCff(_) | NativeFontProgram::DeviceType1(_) => None,
|
||||
| NativeFontProgram::OpenTypeCff(_) | NativeFontProgram::DeviceType1(_)
|
||||
| NativeFontProgram::CompositeType1(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,6 +133,7 @@ pub enum NativeFontProgram {
|
||||
Pk(crate::pk_font::PkFontProgram),
|
||||
TrueType(TrueTypeProgram),
|
||||
OpenTypeCff(OpenTypeCffProgram),
|
||||
CompositeType1(CompositeType1Program),
|
||||
DeviceType1(DeviceType1Program),
|
||||
}
|
||||
impl NativeFontProgram {
|
||||
@@ -138,6 +143,7 @@ impl NativeFontProgram {
|
||||
Self::Pk(p) => &p.name,
|
||||
Self::TrueType(p) => &p.name,
|
||||
Self::OpenTypeCff(p) => &p.name,
|
||||
Self::CompositeType1(p) => &p.font.name,
|
||||
Self::DeviceType1(p) => &p.name,
|
||||
}
|
||||
}
|
||||
@@ -668,16 +674,14 @@ fn resolve_physical_fonts(
|
||||
direct_resolved.insert(id, Arc::new(paint));
|
||||
continue;
|
||||
}
|
||||
if let Some(encoding) = &outline.xdv_encoding
|
||||
&& (outline.encoding.is_none() || files.optional_font_file(
|
||||
ResourceKind::CMap, &encoding.name, &outline.from.to_string_lossy(),
|
||||
)?.is_some())
|
||||
{
|
||||
return Err(format!(
|
||||
"native XDV composite encoding {} requires a TrueType or OpenType CFF program: {}", encoding.name, font.name,
|
||||
));
|
||||
}
|
||||
let file = outline.type1_file(&font.name)?;
|
||||
if let Some(encoding) = &outline.xdv_encoding
|
||||
&& let Some(codes) = composite::Codes::load(encoding, outline, files)?
|
||||
{
|
||||
let paint = composite_type1::resolve(files, font_cache, outline, file, slots, encoding, codes)?;
|
||||
direct_resolved.insert(id, Arc::new(paint));
|
||||
continue;
|
||||
}
|
||||
let version = outline.version.as_ref();
|
||||
let transform = outline.transform;
|
||||
let key = (
|
||||
@@ -790,7 +794,8 @@ fn resolve_physical_fonts(
|
||||
NativeFontProgram::Type1(_)
|
||||
| NativeFontProgram::DeviceType1(_)
|
||||
| NativeFontProgram::TrueType(_)
|
||||
| NativeFontProgram::OpenTypeCff(_) => {
|
||||
| NativeFontProgram::OpenTypeCff(_)
|
||||
| NativeFontProgram::CompositeType1(_) => {
|
||||
crate::type1::glyph_unicode_text(&p.encoding[*slot as usize])
|
||||
.and_then(|text| text.chars().next())
|
||||
.unwrap_or('�')
|
||||
|
||||
Reference in new issue
Block a user