[−][src]Struct embedded_text::style::TextBoxStyle
Styling options of a TextBox.
TextBoxStyle contains the Font, foreground and background PixelColor,
HorizontalTextAlignment and VerticalTextAlignment 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
text_style: TextStyle<C, F>Style properties for text.
alignment: AHorizontal text alignment.
vertical_alignment: VVertical text alignment.
Implementations
impl<C, F, A, V> TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
pub fn new(font: F, text_color: C, alignment: A, vertical_alignment: V) -> Self[src]
Creates a TextBoxStyle object with transparent background.
pub fn from_text_style(
text_style: TextStyle<C, F>,
alignment: A,
vertical_alignment: V
) -> Self[src]
text_style: TextStyle<C, F>,
alignment: A,
vertical_alignment: V
) -> Self
Creates a TextBoxStyle object from the given text style and alignment.
#[must_use]pub fn measure_line<'a>(
&self,
parser: &mut Parser<'a>,
carried_token: Option<Token<'a>>,
max_line_width: u32
) -> (u32, u32, Option<Token<'a>>)[src]
&self,
parser: &mut Parser<'a>,
carried_token: Option<Token<'a>>,
max_line_width: u32
) -> (u32, u32, Option<Token<'a>>)
Measure the width and count spaces in a single line of text.
Returns (width, rendered space count, carried token)
Instead of peeking ahead when processing tokens, this function advances the parser before
processing a token. If a token opens a new line, it will be returned as the carried token.
If the carried token is None, the parser has finished processing the text.
#[must_use]pub fn measure_text_height(&self, text: &str, max_width: u32) -> u32[src]
Measures text height when rendered using a given width.
Example: measure height of text when rendered using a 6x8 font and 72px width.
let style = TextBoxStyleBuilder::new(Font6x8) .text_color(BinaryColor::On) .build(); let height = style.measure_text_height( "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 * 8, height);
Trait Implementations
impl<C: Clone, F: Clone, A: Clone, V: Clone> Clone for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
fn clone(&self) -> TextBoxStyle<C, F, A, V>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<C: Copy, F: Copy, A: Copy, V: Copy> Copy for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
impl<C: Debug, F: Debug, A: Debug, V: Debug> Debug for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
impl<C: Default, F: Default, A: Default, V: Default> Default for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
fn default() -> TextBoxStyle<C, F, A, V>[src]
impl<C: Eq, F: Eq, A: Eq, V: Eq> Eq for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
impl<C: Hash, F: Hash, A: Hash, V: Hash> Hash for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<C: Ord, F: Ord, A: Ord, V: Ord> Ord for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
fn cmp(&self, other: &TextBoxStyle<C, F, A, V>) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl<C: PartialEq, F: PartialEq, A: PartialEq, V: PartialEq> PartialEq<TextBoxStyle<C, F, A, V>> for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
fn eq(&self, other: &TextBoxStyle<C, F, A, V>) -> bool[src]
fn ne(&self, other: &TextBoxStyle<C, F, A, V>) -> bool[src]
impl<C: PartialOrd, F: PartialOrd, A: PartialOrd, V: PartialOrd> PartialOrd<TextBoxStyle<C, F, A, V>> for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
fn partial_cmp(&self, other: &TextBoxStyle<C, F, A, V>) -> Option<Ordering>[src]
fn lt(&self, other: &TextBoxStyle<C, F, A, V>) -> bool[src]
fn le(&self, other: &TextBoxStyle<C, F, A, V>) -> bool[src]
fn gt(&self, other: &TextBoxStyle<C, F, A, V>) -> bool[src]
fn ge(&self, other: &TextBoxStyle<C, F, A, V>) -> bool[src]
impl<C, F, A, V> StructuralEq for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
impl<C, F, A, V> StructuralPartialEq for TextBoxStyle<C, F, A, V> where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
Auto Trait Implementations
impl<C, F, A, V> RefUnwindSafe for TextBoxStyle<C, F, A, V> where
A: RefUnwindSafe,
C: RefUnwindSafe,
F: RefUnwindSafe,
V: RefUnwindSafe,
A: RefUnwindSafe,
C: RefUnwindSafe,
F: RefUnwindSafe,
V: RefUnwindSafe,
impl<C, F, A, V> Send for TextBoxStyle<C, F, A, V> where
A: Send,
C: Send,
F: Send,
V: Send,
A: Send,
C: Send,
F: Send,
V: Send,
impl<C, F, A, V> Sync for TextBoxStyle<C, F, A, V> where
A: Sync,
C: Sync,
F: Sync,
V: Sync,
A: Sync,
C: Sync,
F: Sync,
V: Sync,
impl<C, F, A, V> Unpin for TextBoxStyle<C, F, A, V> where
A: Unpin,
C: Unpin,
F: Unpin,
V: Unpin,
A: Unpin,
C: Unpin,
F: Unpin,
V: Unpin,
impl<C, F, A, V> UnwindSafe for TextBoxStyle<C, F, A, V> where
A: UnwindSafe,
C: UnwindSafe,
F: UnwindSafe,
V: UnwindSafe,
A: UnwindSafe,
C: UnwindSafe,
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,