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 TextBoxStyle::default method or the TextBoxStyleBuilder object.

Fields (Non-exhaustive)

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
alignment: HorizontalAlignment

Horizontal text alignment.

vertical_alignment: VerticalAlignment

Vertical text alignment.

height_mode: HeightMode

The height behaviour.

line_height: LineHeight

Line height.

paragraph_spacing: u32

Paragraph spacing.

tab_size: TabSize

Desired column width for tabs

Implementations

Creates a new text box style object with default settings.

Creates a new text box style with the given alignment.

Creates a new text box style with the given vertical alignment.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Casts the value.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Casts the value.

Performs the conversion.

Performs the conversion.

Casts the value.

Should always be Self

Casts the value.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Casts the value.

Casts the value.