Struct me3_framework::overlay::widget_text::RichText
source · [−]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>) -> RichText
pub fn is_empty(&self) -> bool
pub fn text(&self) -> &str
sourcepub fn size(self, size: f32) -> RichText
pub fn size(self, size: f32) -> RichText
Select the font size (in points).
This overrides the value from Self::text_style
.
sourcepub fn family(self, family: FontFamily) -> RichText
pub fn family(self, family: FontFamily) -> RichText
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) -> RichText
pub fn font(self, font_id: FontId) -> RichText
Select the font and size.
This overrides the value from Self::text_style
.
sourcepub fn text_style(self, text_style: TextStyle) -> RichText
pub fn text_style(self, text_style: TextStyle) -> RichText
Override the TextStyle
.
sourcepub fn fallback_text_style(self, text_style: TextStyle) -> RichText
pub fn fallback_text_style(self, text_style: TextStyle) -> RichText
Set the TextStyle
unless it has already been set
sourcepub fn heading(self) -> RichText
pub fn heading(self) -> RichText
Use TextStyle::Heading
.
sourcepub fn monospace(self) -> RichText
pub fn monospace(self) -> RichText
Use TextStyle::Monospace
.
sourcepub fn underline(self) -> RichText
pub fn underline(self) -> RichText
Draw a line under the text.
If you want to control the line color, use LayoutJob
instead.
sourcepub fn strikethrough(self) -> RichText
pub fn strikethrough(self) -> RichText
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) -> RichText
pub fn small_raised(self) -> RichText
For e.g. exponents.
sourcepub fn raised(self) -> RichText
pub fn raised(self) -> RichText
Align text to top. Only applicable together with Self::small()
.
sourcepub fn background_color(self, background_color: impl Into<Color32>) -> RichText
pub fn background_color(self, background_color: impl Into<Color32>) -> RichText
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.