#[non_exhaustive]pub struct TextBoxStyle {
pub alignment: HorizontalAlignment,
pub vertical_alignment: VerticalAlignment,
pub height_mode: HeightMode,
pub line_height: LineHeight,
pub paragraph_spacing: u32,
pub tab_size: TabSize,
pub leading_spaces: bool,
pub trailing_spaces: bool,
}Expand description
Styling options of a TextBox.
TextBoxStyle contains the font, foreground and background PixelColor, line spacing,
HeightMode, HorizontalAlignment and VerticalAlignment information necessary
to draw a TextBox.
To construct a new TextBoxStyle object, use the TextBoxStyle::default method or
the TextBoxStyleBuilder object.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.alignment: HorizontalAlignmentHorizontal text alignment.
vertical_alignment: VerticalAlignmentVertical text alignment.
height_mode: HeightModeThe height behaviour.
line_height: LineHeightLine height.
paragraph_spacing: u32Paragraph spacing.
tab_size: TabSizeDesired column width for tabs
leading_spaces: boolTrue to render leading spaces
trailing_spaces: boolTrue to render trailing spaces
Implementations§
Source§impl TextBoxStyle
impl TextBoxStyle
Sourcepub const fn with_alignment(alignment: HorizontalAlignment) -> TextBoxStyle
pub const fn with_alignment(alignment: HorizontalAlignment) -> TextBoxStyle
Creates a new text box style with the given alignment.
Sourcepub const fn with_vertical_alignment(
alignment: VerticalAlignment,
) -> TextBoxStyle
pub const fn with_vertical_alignment( alignment: VerticalAlignment, ) -> TextBoxStyle
Creates a new text box style with the given vertical alignment.
Sourcepub const fn with_height_mode(mode: HeightMode) -> TextBoxStyle
pub const fn with_height_mode(mode: HeightMode) -> TextBoxStyle
Creates a new text box style with the given height mode.
Sourcepub const fn with_line_height(line_height: LineHeight) -> TextBoxStyle
pub const fn with_line_height(line_height: LineHeight) -> TextBoxStyle
Creates a new text box style with the given line height.
Sourcepub const fn with_paragraph_spacing(spacing: u32) -> TextBoxStyle
pub const fn with_paragraph_spacing(spacing: u32) -> TextBoxStyle
Creates a new text box style with the given paragraph spacing.
Sourcepub const fn with_tab_size(tab_size: TabSize) -> TextBoxStyle
pub const fn with_tab_size(tab_size: TabSize) -> TextBoxStyle
Creates a new text box style with the given tab size.
Source§impl TextBoxStyle
impl TextBoxStyle
Sourcepub fn measure_text_height<S>(
&self,
character_style: &S,
text: &str,
max_width: u32,
) -> u32where
S: TextRenderer,
pub fn measure_text_height<S>(
&self,
character_style: &S,
text: &str,
max_width: u32,
) -> u32where
S: TextRenderer,
Measures text height when rendered using a given width.
§Example: measure height of text when rendered using a 6x9 MonoFont and 72px width.
let character_style = MonoTextStyleBuilder::new()
.font(&FONT_6X9)
.text_color(BinaryColor::On)
.build();
let style = TextBoxStyleBuilder::new().build();
let height = style.measure_text_height(
&character_style,
"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
72,
);
// Expect 7 lines of text, wrapped in something like the following:
// |Lorem Ipsum |
// |is simply |
// |dummy text |
// |of the |
// |printing and|
// |typesetting |
// |industry. |
assert_eq!(7 * 9, height);Trait Implementations§
Source§impl Clone for TextBoxStyle
impl Clone for TextBoxStyle
Source§fn clone(&self) -> TextBoxStyle
fn clone(&self) -> TextBoxStyle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more