1 | use crate::{pixelcolor::PixelColor, text::DecorationColor}; |
2 | |
3 | /// Character style. |
4 | /// |
5 | /// This trait is used to modify character styles programmatically, for example, to implement |
6 | /// rendering of text with multiple colors. Applications shouldn't use this trait and instead use |
7 | /// the character style types that are provided by the text renderer, like `MonoTextStyle` and |
8 | /// `MonoTextStyleBuilder` for the integrated font support. |
9 | /// |
10 | /// # Implementation notes |
11 | /// |
12 | /// Text renderers don't need to support all settings in this trait. All calls to unsupported |
13 | /// setters should be ignored by the implementation. The trait provided empty default |
14 | /// implementations for all setters. |
15 | pub trait CharacterStyle: Clone { |
16 | /// The color type. |
17 | type Color: PixelColor; |
18 | |
19 | /// Sets the text color. |
20 | fn set_text_color(&mut self, _text_color: Option<Self::Color>) {} |
21 | |
22 | /// Sets the background color. |
23 | fn set_background_color(&mut self, _background_color: Option<Self::Color>) {} |
24 | |
25 | /// Sets the underline color. |
26 | fn set_underline_color(&mut self, _underline_color: DecorationColor<Self::Color>) {} |
27 | |
28 | /// Sets the strikethrough color. |
29 | fn set_strikethrough_color(&mut self, _strikethrough_color: DecorationColor<Self::Color>) {} |
30 | } |
31 | |