Paint colorbox backgrounds
This commit is contained in:
1 parent
eebe6deac5
commit
d88e74cd29
8 files changed
+167
-25
No files matched your search
@@ -6607,6 +6607,41 @@ mod tests {
|
||||
assert!(svg.contains(">s</text>"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn color_box_segments_paint_a_background_rect() {
|
||||
let segments = vec![crate::paragraph::InlineSegment::ColorBox(
|
||||
ParagraphFont::Roman,
|
||||
65_536 * 10,
|
||||
0,
|
||||
[0, 255, 0],
|
||||
"Boxed".into(),
|
||||
)];
|
||||
let style = crate::paragraph::ParagraphStyle {
|
||||
line_width: 480 * 65_536,
|
||||
..crate::paragraph::ParagraphStyle::default()
|
||||
};
|
||||
let unit = Unit::paragraph_with_style_and_segments(1, "Boxed", style, segments);
|
||||
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();
|
||||
let rect = list
|
||||
.items
|
||||
.iter()
|
||||
.find_map(|item| match item {
|
||||
crate::render::DisplayItem::Rect { color, width, .. } => Some((*color, *width)),
|
||||
_ => None,
|
||||
})
|
||||
.expect("background rect");
|
||||
assert_eq!(rect.0, [0, 255, 0]);
|
||||
assert!(rect.1 > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sized_paragraphs_paint_at_their_font_size() {
|
||||
let style = crate::paragraph::ParagraphStyle {
|
||||
|
||||
Reference in new issue
Block a user