pub struct FormattedText {
pub text: InheritableVariable<Vec<char>>,
pub shadow: InheritableVariable<bool>,
pub shadow_brush: InheritableVariable<Brush>,
pub shadow_dilation: InheritableVariable<f32>,
pub shadow_offset: InheritableVariable<Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>>,
pub runs: RunSet,
pub line_indent: InheritableVariable<f32>,
pub line_space: InheritableVariable<f32>,
pub padding: InheritableVariable<Thickness>,
/* private fields */
}Fields§
§text: InheritableVariable<Vec<char>>§shadow: InheritableVariable<bool>§shadow_brush: InheritableVariable<Brush>§shadow_dilation: InheritableVariable<f32>§shadow_offset: InheritableVariable<Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>>§runs: RunSet§line_indent: InheritableVariable<f32>The indent amount of the first line of the text. A negative indent will cause every line except the first to indent.
line_space: InheritableVariable<f32>The space between lines.
padding: InheritableVariable<Thickness>Implementations§
Source§impl FormattedText
impl FormattedText
pub const FONT: &'static str = "font"
pub const TEXT: &'static str = "text"
pub const VERTICAL_ALIGNMENT: &'static str = "vertical_alignment"
pub const HORIZONTAL_ALIGNMENT: &'static str = "horizontal_alignment"
pub const WRAP: &'static str = "wrap"
pub const MASK_CHAR: &'static str = "mask_char"
pub const FONT_SIZE: &'static str = "font_size"
pub const SHADOW: &'static str = "shadow"
pub const SHADOW_BRUSH: &'static str = "shadow_brush"
pub const SHADOW_DILATION: &'static str = "shadow_dilation"
pub const SHADOW_OFFSET: &'static str = "shadow_offset"
pub const RUNS: &'static str = "runs"
pub const LINE_INDENT: &'static str = "line_indent"
pub const LINE_SPACE: &'static str = "line_space"
pub const PADDING: &'static str = "padding"
Source§impl FormattedText
impl FormattedText
pub fn font_at(&self, index: usize) -> Resource<Font> ⓘ
pub fn font_size_at(&self, index: usize) -> f32
pub fn brush_at(&self, index: usize) -> Brush
pub fn shadow_at(&self, index: usize) -> bool
pub fn shadow_brush_at(&self, index: usize) -> Brush
pub fn shadow_dilation_at(&self, index: usize) -> f32
pub fn shadow_offset_at( &self, index: usize, ) -> Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>
pub fn nearest_valid_position(&self, start: Position) -> Position
pub fn get_relative_position_x( &self, start: Position, offset: isize, ) -> Position
pub fn get_relative_position_y( &self, start: Position, offset: isize, ) -> Position
pub fn get_line_range(&self, line: usize) -> Range<Position>
pub fn iter_line_ranges_within( &self, range: Range<Position>, ) -> impl Iterator<Item = Range<Position>>
pub fn end_position(&self) -> Position
pub fn position_range_to_char_index_range( &self, range: Range<Position>, ) -> Range<usize>
Sourcepub fn position_to_char_index_unclamped(
&self,
position: Position,
) -> Option<usize>
pub fn position_to_char_index_unclamped( &self, position: Position, ) -> Option<usize>
Maps input Position to a linear position in character array.
The index returned is the index of the character after the position, which may be
out-of-bounds if the position is at the end of the text.
You should check the index before trying to use it to fetch data from inner array of characters.
Sourcepub fn position_to_char_index_clamped(
&self,
position: Position,
) -> Option<usize>
pub fn position_to_char_index_clamped( &self, position: Position, ) -> Option<usize>
Maps input Position to a linear position in character array.
The index returned is usually the index of the character after the position,
but if the position is at the end of a line, then return the index of the character before the position.
In other words, the last two positions of each line are mapped to the same character index.
Output index will always be valid for fetching if the method returned Some(index).
The index, however, cannot be used for text insertion because it cannot point to a “place after last char”.
Sourcepub fn char_index_to_position(&self, i: usize) -> Option<Position>
pub fn char_index_to_position(&self, i: usize) -> Option<Position>
Maps linear character index (as in string) to its actual location in the text.
pub fn position_to_local( &self, position: Position, ) -> Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>
pub fn local_to_position( &self, point: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>, ) -> Position
pub fn get_glyphs(&self) -> &[TextGlyph]
pub fn get_glyph_draw_values( &self, layer: DrawValueLayer, glyph: &TextGlyph, ) -> GlyphDrawValues
pub fn get_font(&self) -> Resource<Font> ⓘ
pub fn set_font(&mut self, font: Resource<Font>) -> &mut FormattedText
pub fn font_size(&self) -> &StyledProperty<f32>
pub fn super_sampled_font_size(&self) -> f32
pub fn set_font_size( &mut self, font_size: StyledProperty<f32>, ) -> &mut FormattedText
pub fn get_lines(&self) -> &[TextLine]
pub fn set_vertical_alignment( &mut self, vertical_alignment: VerticalAlignment, ) -> &mut FormattedText
pub fn vertical_alignment(&self) -> VerticalAlignment
pub fn set_horizontal_alignment( &mut self, horizontal_alignment: HorizontalAlignment, ) -> &mut FormattedText
pub fn horizontal_alignment(&self) -> HorizontalAlignment
pub fn set_brush(&mut self, brush: Brush) -> &mut FormattedText
pub fn brush(&self) -> Brush
pub fn set_super_sampling_scale(&mut self, scale: f32) -> &mut FormattedText
pub fn set_constraint( &mut self, constraint: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>, ) -> &mut FormattedText
pub fn get_raw_text(&self) -> &[char]
pub fn text(&self) -> String
pub fn text_range(&self, range: Range<usize>) -> String
Sourcepub fn get_char_width(&self, index: usize) -> Option<f32>
pub fn get_char_width(&self, index: usize) -> Option<f32>
The width of the character at the given index.
Sourcepub fn get_range_width<T>(&self, range: T) -> f32where
T: IntoIterator<Item = usize>,
pub fn get_range_width<T>(&self, range: T) -> f32where
T: IntoIterator<Item = usize>,
The width of the characters at the indices in the given iterator.
This is equivalent to calling get_char_width repeatedly and summing the results.
Sourcepub fn text_rect<R>(&self, line: usize, range: R) -> Option<Rect<f32>>where
R: RangeBounds<usize>,
pub fn text_rect<R>(&self, line: usize, range: R) -> Option<Rect<f32>>where
R: RangeBounds<usize>,
A rectangle relative to the top-left corner of the text that contains the given
range of characters on the given line. None is returned if the line is out of
bounds. The range is relative to the start of the line, so 0 is the first character
of the line, not the first character of the text.
This rect is appropriate for drawing a selection or highlight for the text, and the lower edge of the rectangle can be used to draw an underline.
pub fn set_text<P>(&mut self, text: P) -> &mut FormattedText
pub fn set_chars(&mut self, text: Vec<char>) -> &mut FormattedText
pub fn set_wrap(&mut self, wrap: WrapMode) -> &mut FormattedText
Sourcepub fn set_shadow(&mut self, shadow: bool) -> &mut FormattedText
pub fn set_shadow(&mut self, shadow: bool) -> &mut FormattedText
Sets whether the shadow enabled or not.
Sourcepub fn set_shadow_brush(&mut self, brush: Brush) -> &mut FormattedText
pub fn set_shadow_brush(&mut self, brush: Brush) -> &mut FormattedText
Sets desired shadow brush. It will be used to render the shadow.
Sourcepub fn set_shadow_dilation(&mut self, thickness: f32) -> &mut FormattedText
pub fn set_shadow_dilation(&mut self, thickness: f32) -> &mut FormattedText
Sets desired shadow dilation in units. Keep in mind that the dilation is absolute, not percentage-based.
Sourcepub fn set_shadow_offset(
&mut self,
offset: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>,
) -> &mut FormattedText
pub fn set_shadow_offset( &mut self, offset: Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>, ) -> &mut FormattedText
Sets desired shadow offset in units.
Sourcepub fn runs(&self) -> &RunSet
pub fn runs(&self) -> &RunSet
Runs can optionally modify various style settings for portions of the text. Later runs override earlier runs if their ranges overlap and the later run sets a property that conflicts with an earlier run.
Sourcepub fn runs_mut(&mut self) -> &mut RunSet
pub fn runs_mut(&mut self) -> &mut RunSet
Modify runs of the text to set the style for portions of the text. Later runs potentially override earlier runs if the ranges of the runs overlap and the later run sets a property that conflicts with an earlier run.
Sourcepub fn set_runs(&mut self, runs: RunSet) -> &mut FormattedText
pub fn set_runs(&mut self, runs: RunSet) -> &mut FormattedText
Replace runs of the text to set the style for portions of the text. Later runs potentially override earlier runs if the ranges of the runs overlap and the later run sets a property that conflicts with an earlier run.
Sourcepub fn set_line_indent(&mut self, indent: f32) -> &mut FormattedText
pub fn set_line_indent(&mut self, indent: f32) -> &mut FormattedText
The amount of indent of the first line, horizontally separating it from the start of the remaining lines. If the indent is negative, then the first line will not be indented while all the other lines will be indented. By default, this is 0.0.
Sourcepub fn line_indent(&mut self) -> f32
pub fn line_indent(&mut self) -> f32
The amount of indent of the first line, horizontally separating it from the start of the remaining lines. If the indent is negative, then the first line will not be indented while all the other lines will be indented. By default, this is 0.0.
Sourcepub fn set_line_space(&mut self, space: f32) -> &mut FormattedText
pub fn set_line_space(&mut self, space: f32) -> &mut FormattedText
The space separating each line from the line above and below. By default, this is 0.0.
Sourcepub fn line_space(&self) -> f32
pub fn line_space(&self) -> f32
The space separating each line from the line above and below. By default, this is 0.0.
pub fn wrap_mode(&self) -> WrapMode
pub fn insert_char(&mut self, code: char, index: usize) -> &mut FormattedText
pub fn insert_str(&mut self, str: &str, position: usize) -> &mut FormattedText
pub fn remove_range(&mut self, range: Range<usize>) -> &mut FormattedText
pub fn remove_at(&mut self, index: usize) -> &mut FormattedText
Sourcepub async fn wait_for_fonts(&mut self) -> Result<(), LoadError>
pub async fn wait_for_fonts(&mut self) -> Result<(), LoadError>
Returns once all fonts used by this FormattedText are finished loading.
Sourcepub fn are_fonts_loaded(&self) -> bool
pub fn are_fonts_loaded(&self) -> bool
Returns true if all fonts used by this resource are Ok.
This FormattedText will not build successfully unless this returns true.
pub fn are_fonts_loading(&self) -> bool
pub fn font_load_error_list(&self) -> Vec<(PathBuf, LoadError)>
pub fn font_loading_summary(&self) -> String
pub fn build( &mut self, ) -> Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>
Trait Implementations§
Source§impl Clone for FormattedText
impl Clone for FormattedText
Source§fn clone(&self) -> FormattedText
fn clone(&self) -> FormattedText
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FormattedText
impl Debug for FormattedText
Source§impl Default for FormattedText
impl Default for FormattedText
Source§fn default() -> FormattedText
fn default() -> FormattedText
Source§impl Reflect for FormattedTextwhere
FormattedText: 'static,
impl Reflect for FormattedTextwhere
FormattedText: 'static,
fn source_path() -> &'static str
fn try_clone_box(&self) -> Option<Box<dyn Reflect>>
fn type_name(&self) -> &'static str
fn derived_types() -> &'static [TypeId]
fn query_derived_types(&self) -> &'static [TypeId]
fn doc(&self) -> &'static str
Source§fn assembly_name(&self) -> &'static str
fn assembly_name(&self) -> &'static str
#[derive(Reflect)]) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.Source§fn type_assembly_name() -> &'static str
fn type_assembly_name() -> &'static str
#[derive(Reflect)]) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.fn fields_ref(&self, func: &mut dyn FnMut(&[FieldRef<'_, '_>]))
fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [FieldMut<'_, '_>]))
fn into_any(self: Box<FormattedText>) -> Box<dyn Any>
fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn as_any(&self, func: &mut dyn FnMut(&(dyn Any + 'static)))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Any + 'static)))
fn as_reflect(&self, func: &mut dyn FnMut(&(dyn Reflect + 'static)))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut (dyn Reflect + 'static)))
Source§fn set_field(
&mut self,
field_name: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, SetFieldError>),
)
fn set_field( &mut self, field_name: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, SetFieldError>), )
#[reflect(setter = ..)] or falls back to
Reflect::field_mutfn field( &self, name: &str, func: &mut dyn FnMut(Option<&(dyn Reflect + 'static)>), )
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut (dyn Reflect + 'static)>), )
fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))
fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )
fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))
fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )
fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )
fn as_handle( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHandle + 'static)>), )
fn as_handle_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHandle + 'static)>), )
Source§impl Visit for FormattedText
impl Visit for FormattedText
Source§fn visit(&mut self, name: &str, visitor: &mut Visitor) -> Result<(), VisitError>
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> Result<(), VisitError>
Auto Trait Implementations§
impl !Freeze for FormattedText
impl !RefUnwindSafe for FormattedText
impl Send for FormattedText
impl !Sync for FormattedText
impl Unpin for FormattedText
impl !UnwindSafe for FormattedText
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FieldValue for Twhere
T: Reflect,
impl<T> FieldValue for Twhere
T: Reflect,
Source§fn field_value_as_any_ref(&self) -> &(dyn Any + 'static)
fn field_value_as_any_ref(&self) -> &(dyn Any + 'static)
self to a &dyn AnySource§fn field_value_as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn field_value_as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self to a &mut dyn Anyfn field_value_as_reflect(&self) -> &(dyn Reflect + 'static)
fn field_value_as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn type_name(&self) -> &'static str
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T, U> ObjectOrVariant<T> for Uwhere
PhantomData<U>: ObjectOrVariantHelper<T, U>,
impl<T, U> ObjectOrVariant<T> for Uwhere
PhantomData<U>: ObjectOrVariantHelper<T, U>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> ReflectBase for Twhere
T: Reflect,
impl<T> ReflectBase for Twhere
T: Reflect,
fn as_any_raw(&self) -> &(dyn Any + 'static)
fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )
fn get_resolve_path<'p, T>(
&self,
path: &'p str,
func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>),
)where
T: Reflect,
fn get_resolve_path_mut<'p, T>(
&mut self,
path: &'p str,
func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>),
)where
T: Reflect,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.