Use per-face Computer Modern TFMs for paragraph layout
This commit is contained in:
1 parent
7cb5b42429
commit
521c87d952
9 files changed
+136
-26
No files matched your search
@@ -176,9 +176,13 @@ fn tounicode_cmap(face: &'static PdfFace, characters: &BTreeSet<char>) -> Vec<u8
|
||||
map.into_bytes()
|
||||
}
|
||||
|
||||
fn cid_widths(face: &'static PdfFace, used: &std::collections::BTreeSet<char>) -> String {
|
||||
fn cid_widths(
|
||||
face: &'static PdfFace,
|
||||
slot: usize,
|
||||
used: &std::collections::BTreeSet<char>,
|
||||
) -> String {
|
||||
let font = face_font(face);
|
||||
let metrics = Cmr10Metrics::new();
|
||||
let metrics = Cmr10Metrics::for_pdf_slot(slot);
|
||||
let mut entries = Vec::new();
|
||||
let mut characters = used.clone();
|
||||
characters.extend((0x20u8..=0x7e).map(char::from));
|
||||
@@ -365,7 +369,7 @@ pub fn display_lists_to_pdf(pages: &[DisplayList], page_height: i64) -> Vec<u8>
|
||||
objects.push(
|
||||
format!(
|
||||
"<< /Type /Font /Subtype /CIDFontType2 /BaseFont /{base} /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor {descriptor_id} 0 R /DW 500 /W {} >>",
|
||||
cid_widths(face, &used_chars[slot])
|
||||
cid_widths(face, slot, &used_chars[slot])
|
||||
)
|
||||
.into_bytes(),
|
||||
);
|
||||
@@ -558,7 +562,7 @@ mod tests {
|
||||
let id = face_font(face).glyph(accent).id().0;
|
||||
let mut used = BTreeSet::new();
|
||||
used.insert(accent);
|
||||
let widths = cid_widths(face, &used);
|
||||
let widths = cid_widths(face, 0, &used);
|
||||
assert!(widths.contains(&format!("{id} [500]")), "{widths}");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user