Render legacy XeLaTeX composite TrueType fonts
This commit is contained in:
1 parent
7d460e0fa1
commit
bbeeca0317
11 files changed
+687
-55
No files matched your search
@@ -626,6 +626,7 @@ struct PageContent {
|
||||
bytes: Vec<u8>,
|
||||
origin: crate::pdf_device::DeviceOrigin,
|
||||
measuring: bool,
|
||||
track_legacy_cids: bool,
|
||||
}
|
||||
|
||||
impl PageContent {
|
||||
@@ -724,6 +725,8 @@ pub(crate) fn prepare_text_spaces(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) use native_text::legacy_cid_positions;
|
||||
|
||||
fn page_content(
|
||||
list: &DisplayList,
|
||||
height: i64,
|
||||
@@ -895,7 +898,7 @@ fn page_content(
|
||||
if tex_text.is_none() {
|
||||
content.move_origin(page_origin, list.units, digits);
|
||||
}
|
||||
native_text::NativeText::glyph(
|
||||
let _ = native_text::NativeText::glyph(
|
||||
&mut tex_text,
|
||||
&mut content,
|
||||
*x,
|
||||
@@ -1918,6 +1921,9 @@ fn write_native_font(
|
||||
if let NativeFontProgram::Pk(pk) = &paint.program {
|
||||
return Ok(pk_fonts::write_font(objects, face.id, pk, used, compression, target));
|
||||
}
|
||||
if let NativeFontProgram::TrueType(program) = &paint.program && program.composite.is_some() {
|
||||
return truetype_fonts::write_cid(objects, program, used.keys().copied(), compression, subset_tags, target);
|
||||
}
|
||||
let id = target.unwrap_or_else(|| {
|
||||
objects.push(Vec::new());
|
||||
objects.len()
|
||||
@@ -2513,10 +2519,17 @@ fn write_pdf(
|
||||
|
||||
let xdv_font_aliases: BTreeMap<_, _> = {
|
||||
let mut owners = HashMap::new();
|
||||
let mut cid_owners = HashMap::new();
|
||||
native_used.iter().filter_map(|(&id, (_, paint, _))| {
|
||||
paint.xdv_descriptor?;
|
||||
let key = (paint.type1_program_key()?, paint.encoding_version());
|
||||
let owner = *owners.entry(key).or_insert(id);
|
||||
let owner = if let crate::native_font::NativeFontProgram::TrueType(program) = &paint.program
|
||||
&& let Some(composite) = &program.composite
|
||||
{
|
||||
*cid_owners.entry((paint.program_version()?, program.face_index, composite)).or_insert(id)
|
||||
} else {
|
||||
paint.xdv_descriptor?;
|
||||
let key = (paint.type1_program_key()?, paint.encoding_version());
|
||||
*owners.entry(key).or_insert(id)
|
||||
};
|
||||
(owner != id).then_some((id, owner))
|
||||
}).collect()
|
||||
};
|
||||
@@ -2541,7 +2554,7 @@ fn write_pdf(
|
||||
{
|
||||
return Err("shared PDF font has inconsistent output encoding or program".into());
|
||||
}
|
||||
if xdv_font_aliases.contains_key(&id) {
|
||||
if paint.xdv_descriptor.is_some() && xdv_font_aliases.contains_key(&id) {
|
||||
// Separate map entries can resolve to the same physical
|
||||
// program with disjoint sets of measured glyph widths.
|
||||
for slot in used.keys() {
|
||||
|
||||
Reference in new issue
Block a user