pub struct RichText { /* private fields */ }
Expand description
Text and optional style choices for it.
The style choices (font, color) are applied to the entire text.
For more detailed control, use crate::text::LayoutJob
instead.
A RichText
can be used in most widgets and helper functions, e.g. Ui::label
and Ui::button
.
Example
use egui::{RichText, Color32};
RichText::new("Plain");
RichText::new("colored").color(Color32::RED);
RichText::new("Large and underlined").size(20.0).underline();
Implementations
sourceimpl RichText
impl RichText
pub fn new(text: impl Into<String>) -> Self
pub fn is_empty(&self) -> bool
pub fn text(&self) -> &str
sourcepub fn size(self, size: f32) -> Self
pub fn size(self, size: f32) -> Self
Select the font size (in points).
This overrides the value from Self::text_style
.
sourcepub fn family(self, family: FontFamily) -> Self
pub fn family(self, family: FontFamily) -> Self
Select the font family.
This overrides the value from Self::text_style
.
Only the families available in crate::FontDefinitions::families
may be used.
sourcepub fn font(self, font_id: FontId) -> Self
pub fn font(self, font_id: FontId) -> Self
Select the font and size.
This overrides the value from Self::text_style
.
sourcepub fn text_style(self, text_style: TextStyle) -> Self
pub fn text_style(self, text_style: TextStyle) -> Self
Override the TextStyle
.
sourcepub fn fallback_text_style(self, text_style: TextStyle) -> Self
pub fn fallback_text_style(self, text_style: TextStyle) -> Self
Set the TextStyle
unless it has already been set
sourcepub fn heading(self) -> Self
pub fn heading(self) -> Self
Use TextStyle::Heading
.
sourcepub fn monospace(self) -> Self
pub fn monospace(self) -> Self
Use TextStyle::Monospace
.
sourcepub fn underline(self) -> Self
pub fn underline(self) -> Self
Draw a line under the text.
If you want to control the line color, use LayoutJob
instead.
sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Draw a line through the text, crossing it out.
If you want to control the strikethrough line color, use LayoutJob
instead.
sourcepub fn small_raised(self) -> Self
pub fn small_raised(self) -> Self
For e.g. exponents.
sourcepub fn raised(self) -> Self
pub fn raised(self) -> Self
Align text to top. Only applicable together with Self::small()
.
sourcepub fn background_color(self, background_color: impl Into<Color32>) -> Self
pub fn background_color(self, background_color: impl Into<Color32>) -> Self
Fill-color behind the text.
sourcepub fn font_height(&self, fonts: &Fonts, style: &Style) -> f32
pub fn font_height(&self, fonts: &Fonts, style: &Style) -> f32
Read the font height of the selected text style.
Trait Implementations
sourceimpl From<RichText> for WidgetText
impl From<RichText> for WidgetText
impl StructuralPartialEq for RichText
Auto Trait Implementations
impl RefUnwindSafe for RichText
impl Send for RichText
impl Sync for RichText
impl Unpin for RichText
impl UnwindSafe for RichText
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more