Paint ligature boxes as their component letters

This commit is contained in:
gloamxun committed 2026-10-20 22:59:31 +08:00
1 parent 67915402a6
commit ff3fff343d
3 files changed
+32 -3

No files matched your search

+18
View File
@@ -1600,6 +1600,24 @@ mod tests {
assert_eq!(before, after);
}
#[test]
fn ligature_boxes_paint_their_component_letters() {
let unit = Unit::paragraph(1, "office");
let page = Page {
items: unit.items,
insertions: Vec::new(),
marks: Vec::new(),
floats: Vec::new(),
sources: Vec::new(),
hash: 0,
};
let list = page.display_list();
assert!(list.items.iter().any(|item| matches!(
item,
crate::render::DisplayItem::Text { text, .. } if text == "ff"
)));
}
#[test]
fn paragraph_widths_come_from_cmr10_not_fixed_cells() {
let width = |source: &str| {
+12 -1
View File
@@ -250,6 +250,17 @@ fn escape(text: &str) -> String {
.replace('>', ">")
}
fn character_text(character: char) -> String {
match character {
'\u{FB00}' => "ff".to_owned(),
'\u{FB01}' => "fi".to_owned(),
'\u{FB02}' => "fl".to_owned(),
'\u{FB03}' => "ffi".to_owned(),
'\u{FB04}' => "ffl".to_owned(),
_ => character.to_string(),
}
}
impl Halign {
/// Convert the table into text and rule primitives, with the table origin
/// at `(0, 0)`.
@@ -403,7 +414,7 @@ impl Page {
x,
y: baseline,
size,
text: character.to_string(),
text: character_text(character),
});
}
x += box_.width;