Struct egui::text::LayoutJob [−][src]
pub struct LayoutJob {
pub text: String,
pub sections: Vec<LayoutSection, Global>,
pub wrap_width: f32,
pub first_row_min_height: f32,
pub break_on_newline: bool,
pub halign: Align,
pub justify: bool,
}
Expand description
Describes the task of laying out text.
This supports mixing different fonts, color and formats (underline etc).
Pass this to crate::Fonts::layout_job
or crate::text::layout
.
Example:
use epaint::{Color32, text::{LayoutJob, TextFormat}, TextStyle};
let mut job = LayoutJob::default();
job.append(
"Hello ",
0.0,
TextFormat {
style: TextStyle::Body,
color: Color32::WHITE,
..Default::default()
},
);
job.append(
"World!",
0.0,
TextFormat {
style: TextStyle::Monospace,
color: Color32::BLACK,
..Default::default()
},
);
Fields
text: String
The complete text of this job, referenced by LayoutSection
.
sections: Vec<LayoutSection, Global>
The different section, which can have different fonts, colors, etc.
wrap_width: f32
Try to break text so that no row is wider than this.
Set to f32::INFINITY
to turn off wrapping.
Note that \n
always produces a new line.
first_row_min_height: f32
The first row must be at least this high.
This is in case we lay out text that is the continuation
of some earlier text (sharing the same row),
in which case this will be the height of the earlier text.
In other cases, set this to 0.0
.
break_on_newline: bool
If false
, all newlines characters will be ignored
and show up as the replacement character.
Default: true
.
halign: Align
How to horizontally align the text (Align::LEFT
, Align::Center
, Align::RIGHT
).
justify: bool
Justify text so that word-wrapped rows fill the whole Self::wrap_width
Implementations
Break on \n
and at the given wrap width.
Does not break on \n
, but shows the replacement character instead.
Helper for adding a new section when building a LayoutJob
.
Trait Implementations
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<LayoutJob, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<LayoutJob, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for LayoutJob
impl UnwindSafe for LayoutJob
Blanket Implementations
Mutably borrows from an owned value. Read more