From abdbad308f0237fec3c908b8ae94834ee701286a Mon Sep 17 00:00:00 2001 From: Hojjat Date: Tue, 24 Feb 2026 15:59:37 -0700 Subject: [PATCH] test: text decoration for bidi text is different test: bidi and rtl tests for text decoration --- tests/images/text_decoration_bidi.png | 3 ++ tests/images/text_decoration_rtl.png | 3 ++ tests/text_decorations.rs | 76 +++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/images/text_decoration_bidi.png create mode 100644 tests/images/text_decoration_rtl.png diff --git a/tests/images/text_decoration_bidi.png b/tests/images/text_decoration_bidi.png new file mode 100644 index 0000000..19757e5 --- /dev/null +++ b/tests/images/text_decoration_bidi.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae146ba5d50c22ece61ffa9d451e97c570a31b20f743b22d5e739838c6c69871 +size 15179 diff --git a/tests/images/text_decoration_rtl.png b/tests/images/text_decoration_rtl.png new file mode 100644 index 0000000..637070a --- /dev/null +++ b/tests/images/text_decoration_rtl.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ff310b1066319bafa525de0f4580a26618c0be48320dc2b17756363ea70cf4d +size 12525 diff --git a/tests/text_decorations.rs b/tests/text_decorations.rs index be0d343..5be8e74 100644 --- a/tests/text_decorations.rs +++ b/tests/text_decorations.rs @@ -49,3 +49,79 @@ fn test_text_decorations() { .canvas(600, 50) .validate_text_rendering(); } + + +#[test] +fn test_text_decorations_rtl() { + let base = base_attrs(); + let red = Color::rgb(0xFF, 0x00, 0x00); + let cyan = Color::rgb(0x00, 0xFF, 0xFF); + + DrawTestCfg::new("text_decoration_rtl") + .font_size(20., 26.) + .font_attrs(base.clone()) + .rich_text(vec![ + ("زیر خط ", base.clone().underline(UnderlineStyle::Single)), + ("دوتایی ", base.clone().underline(UnderlineStyle::Double)), + ("خط ", base.clone().strikethrough()), + ("رو ", base.clone().overline()), + ( + "زیر خط قرمز ", + base.clone() + .underline(UnderlineStyle::Single) + .underline_color(red), + ), + ( + "فیروزه ای ", + base.clone().strikethrough().strikethrough_color(cyan), + ), + ( + "همگی", + base.clone() + .underline(UnderlineStyle::Single) + .strikethrough() + .overline(), + ), + (" هیچ", base), + ]) + .canvas(600, 50) + .validate_text_rendering(); +} + +/// Bidi test +#[test] +fn test_text_decorations_bidi() { + let base = base_attrs(); + let red = Color::rgb(0xFF, 0x00, 0x00); + let cyan = Color::rgb(0x00, 0xFF, 0xFF); + + DrawTestCfg::new("text_decoration_bidi") + .font_size(20., 26.) + .font_attrs(base.clone()) + .rich_text(vec![ + ("زیرخط ", base.clone().underline(UnderlineStyle::Single)), + ("Double ", base.clone().underline(UnderlineStyle::Double)), + ("خط ", base.clone().strikethrough()), + ("Over ", base.clone().overline()), + ( + "Red زیر خط ", + 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(); +}