Carry paragraph font faces through the display list

This commit is contained in:
gloamxun committed 2026-10-20 18:32:33 +08:00
1 parent 96c88d2787
commit 6b74a17312
4 files changed
+54 -5

No files matched your search

+19 -1
View File
@@ -57,11 +57,27 @@ impl Default for ParagraphStyle {
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ParagraphFont {
Roman,
Bold,
Italic,
}
impl Default for ParagraphFont {
fn default() -> Self {
Self::Roman
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct Paragraph {
pub lines: Vec<Vec<HorizontalItem>>,
pub height: i64,
pub width: i64,
#[serde(default)]
pub font: ParagraphFont,
}
impl Paragraph {
@@ -118,6 +134,7 @@ pub fn layout_items(items: &[HorizontalItem], style: &ParagraphStyle) -> Paragra
lines: Vec::new(),
height: 0,
width: 0,
font: ParagraphFont::Roman,
};
}
let mut breakpoints = vec![0_usize];
@@ -286,6 +303,7 @@ pub fn layout_items(items: &[HorizontalItem], style: &ParagraphStyle) -> Paragra
height: lines.len() as i64 * style.line_height,
width: max_width,
lines,
font: ParagraphFont::Roman,
}
}