test: text decoration test
This commit is contained in:
parent
78665aab3b
commit
61f001b0f7
2 changed files with 54 additions and 0 deletions
3
tests/images/text_decorations.png
Normal file
3
tests/images/text_decorations.png
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8639df22ce9e580c5e75dd1163cf05a79691d18ed49156d173a9e7222db44538
|
||||
size 16685
|
||||
51
tests/text_decorations.rs
Normal file
51
tests/text_decorations.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use common::DrawTestCfg;
|
||||
use cosmic_text::{Attrs, Color, Family, UnderlineStyle};
|
||||
|
||||
mod common;
|
||||
|
||||
fn base_attrs() -> Attrs<'static> {
|
||||
Attrs::new().family(Family::Name("Noto Sans"))
|
||||
}
|
||||
|
||||
/// Single test covering all decoration variants:
|
||||
/// - Single underline, double underline
|
||||
/// - Strikethrough, overline
|
||||
/// - Colored underline (red), colored strikethrough (cyan)
|
||||
/// - All three combined on one span
|
||||
/// - Plain text (no decoration) between spans
|
||||
#[test]
|
||||
fn test_text_decorations() {
|
||||
let base = base_attrs();
|
||||
let red = Color::rgb(0xFF, 0x00, 0x00);
|
||||
let cyan = Color::rgb(0x00, 0xFF, 0xFF);
|
||||
|
||||
DrawTestCfg::new("text_decorations")
|
||||
.font_size(20., 26.)
|
||||
.font_attrs(base.clone())
|
||||
.rich_text(vec![
|
||||
("Under ", base.clone().underline(UnderlineStyle::Single)),
|
||||
("Double ", base.clone().underline(UnderlineStyle::Double)),
|
||||
("Strike ", base.clone().strikethrough()),
|
||||
("Over ", base.clone().overline()),
|
||||
(
|
||||
"RedUl ",
|
||||
base.clone()
|
||||
.underline(UnderlineStyle::Single)
|
||||
.underline_color(red),
|
||||
),
|
||||
(
|
||||
"CyanSt ",
|
||||
base.clone().strikethrough().strikethrough_color(cyan),
|
||||
),
|
||||
(
|
||||
"All",
|
||||
base.clone()
|
||||
.underline(UnderlineStyle::Single)
|
||||
.strikethrough()
|
||||
.overline(),
|
||||
),
|
||||
(" Plain", base),
|
||||
])
|
||||
.canvas(600, 50)
|
||||
.validate_text_rendering();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue