Struct embedded_text::style::TextBoxStyle [−][src]
#[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, }
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 new or from_text_style methods 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
Implementations
Creates a new text box style with the given alignment.
Creates a new text box style with the given vertical alignment.
pub fn measure_text_height<S>(
&self,
character_style: &S,
text: &str,
max_width: u32
) -> u32 where
S: TextRenderer,
S::Color: From<Rgb888>,
pub fn measure_text_height<S>(
&self,
character_style: &S,
text: &str,
max_width: u32
) -> u32 where
S: TextRenderer,
S::Color: From<Rgb888>, Measures text height when rendered using a given width.
Example: measure height of text when rendered using a 6x8 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
Performs the conversion.
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl RefUnwindSafe for TextBoxStyleimpl Send for TextBoxStyleimpl Sync for TextBoxStyleimpl Unpin for TextBoxStyleimpl UnwindSafe for TextBoxStyleBlanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
type Output = T
type Output = TShould always be Self
Casts the value.
Casts the value.
Casts the value.