Struct embedded_text::style::height_mode::ShrinkToText [−][src]
pub struct ShrinkToText<OV: VerticalOverdraw>(pub OV);
If the text does not fill the bounding box, shrink the StyledTextBox to be as tall as the
text.
Example: ShrinkToText does not grow the TextBox.
use embedded_text::{prelude::*, style::vertical_overdraw::FullRowsOnly}; use embedded_graphics::{fonts::Font6x8, pixelcolor::BinaryColor, prelude::*}; // This TextBox contains two lines of text, but is 1px high let text_box = TextBox::new( "Two lines\nof text", Rectangle::new(Point::zero(), Point::new(59, 0)), ); // Set style, use 6x8 font so the 2 lines are 16px high. let style = TextBoxStyleBuilder::new(Font6x8) .height_mode(ShrinkToText(FullRowsOnly)) .text_color(BinaryColor::On) .build(); let size = text_box.into_styled(style).size(); assert_eq!(size, Size::new(60, 1));
Example: ShrinkToText shrinks the TextBox.
use embedded_text::{prelude::*, style::vertical_overdraw::FullRowsOnly}; use embedded_graphics::{fonts::Font6x8, pixelcolor::BinaryColor, prelude::*}; // This TextBox contains two lines of text, but is 60px high let text_box = TextBox::new( "Two lines\nof text", Rectangle::new(Point::zero(), Point::new(59, 59)), ); // Set style, use 6x8 font so the 2 lines are 16px high. let style = TextBoxStyleBuilder::new(Font6x8) .height_mode(ShrinkToText(FullRowsOnly)) .text_color(BinaryColor::On) .build(); let size = text_box.into_styled(style).size(); assert_eq!(size, Size::new(60, 16));
Trait Implementations
impl<OV: Clone + VerticalOverdraw> Clone for ShrinkToText<OV>[src]
impl<OV: Clone + VerticalOverdraw> Clone for ShrinkToText<OV>[src]fn clone(&self) -> ShrinkToText<OV>[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<OV: Copy + VerticalOverdraw> Copy for ShrinkToText<OV>[src]
impl<OV: Copy + VerticalOverdraw> Copy for ShrinkToText<OV>[src]impl<OV: Debug + VerticalOverdraw> Debug for ShrinkToText<OV>[src]
impl<OV: Debug + VerticalOverdraw> Debug for ShrinkToText<OV>[src]impl<OV> HeightMode for ShrinkToText<OV> where
OV: VerticalOverdraw, [src]
impl<OV> HeightMode for ShrinkToText<OV> where
OV: VerticalOverdraw, [src]fn apply<C, F, A, V, H>(text_box: &mut StyledTextBox<'_, C, F, A, V, H>) where
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode, [src]
C: PixelColor,
F: Font + Copy,
A: HorizontalTextAlignment,
V: VerticalTextAlignment,
H: HeightMode,
fn calculate_displayed_row_range<F: Font>(cursor: &Cursor<F>) -> Range<i32>[src]
Auto Trait Implementations
impl<OV> RefUnwindSafe for ShrinkToText<OV> where
OV: RefUnwindSafe,
impl<OV> RefUnwindSafe for ShrinkToText<OV> where
OV: RefUnwindSafe, impl<OV> Send for ShrinkToText<OV> where
OV: Send,
impl<OV> Send for ShrinkToText<OV> where
OV: Send, impl<OV> Sync for ShrinkToText<OV> where
OV: Sync,
impl<OV> Sync for ShrinkToText<OV> where
OV: Sync, impl<OV> Unpin for ShrinkToText<OV> where
OV: Unpin,
impl<OV> Unpin for ShrinkToText<OV> where
OV: Unpin, impl<OV> UnwindSafe for ShrinkToText<OV> where
OV: UnwindSafe,
impl<OV> UnwindSafe for ShrinkToText<OV> where
OV: UnwindSafe,