Paint paragraph glyphs in the route-D display list

This commit is contained in:
gloamxun committed 2026-10-20 13:42:58 +08:00
1 parent d07ff59d31
commit 38bacdfbd5
4 files changed
+271 -193

No files matched your search

+7 -1
View File
@@ -6,6 +6,8 @@ pub struct HorizontalBox {
pub width: i64,
pub height: i64,
pub depth: i64,
/// The source character when this box came from text, for display lists.
pub character: Option<char>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
@@ -55,7 +57,7 @@ impl Default for ParagraphStyle {
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Paragraph {
pub lines: Vec<Vec<HorizontalItem>>,
pub height: i64,
@@ -86,6 +88,7 @@ pub fn text_items(text: &str, style: &ParagraphStyle) -> Vec<HorizontalItem> {
width: style.char_width,
height: style.line_height,
depth: 0,
character: Some(character),
}));
}
}
@@ -247,12 +250,14 @@ pub fn layout_items(items: &[HorizontalItem], style: &ParagraphStyle) -> Paragra
width: *pre_break_width,
height: style.line_height,
depth: 0,
character: Some('-'),
}));
} else if *no_break_width > 0 {
line.push(HorizontalItem::Box(HorizontalBox {
width: *no_break_width,
height: style.line_height,
depth: 0,
character: None,
}));
}
}
@@ -317,6 +322,7 @@ pub fn text_items_with_font(
width: font.width(character),
height: style.line_height,
depth: 0,
character: Some(character),
}));
let boundary = character_index + 1;
if points.contains(&boundary) && boundary >= 2 && boundary + 2 <= word.chars().count() {