Struct embedded_text::style::TextBoxStyle
source · #[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,
S::Color: From<Rgb888>,
pub fn measure_text_height<S>( &self, character_style: &S, text: &str, max_width: u32 ) -> u32where S: TextRenderer, S::Color: From<Rgb888>,
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 moresource§impl Debug for TextBoxStyle
impl Debug for TextBoxStyle
source§impl From<&TextBoxStyle> for TextBoxStyleBuilder
impl From<&TextBoxStyle> for TextBoxStyleBuilder
source§fn from(style: &TextBoxStyle) -> Self
fn from(style: &TextBoxStyle) -> Self
source§impl Hash for TextBoxStyle
impl Hash for TextBoxStyle
source§impl PartialEq<TextBoxStyle> for TextBoxStyle
impl PartialEq<TextBoxStyle> for TextBoxStyle
source§fn eq(&self, other: &TextBoxStyle) -> bool
fn eq(&self, other: &TextBoxStyle) -> bool
self and other values to be equal, and is used
by ==.