pub struct Text {Show 17 fields
pub buffer: Buffer,
pub pos: Vec3,
pub size: Vec2,
pub scale: f32,
pub default_color: Color,
pub bounds: Bounds,
pub store_id: Index,
pub render_layer: u32,
pub order: DrawOrder,
pub cursor: Cursor,
pub line: usize,
pub scroll: Scroll,
pub wrap: Wrap,
pub camera_type: CameraType,
pub glyph_vertices: Vec<TextVertex>,
pub order_override: Option<Vec3>,
pub changed: bool,
}Expand description
Text to render to screen.
Fields§
§buffer: BufferCosmic Text Buffer.
pos: Vec3Position on the Screen.
size: Vec2Width and Height of the Text Area.
scale: f32Scale of the Text.
default_color: ColorDefault Text Font Color.
bounds: BoundsClip Bounds of Text.
store_id: IndexInstance Buffer Store Index of Text Buffer.
render_layer: u32Rendering Layer of the Text used in DrawOrder.
order: DrawOrderthe draw order of the Text. created/updated when update is called.
cursor: CursorCursor the shaping is set too.
line: usizeline the shaping is set too.
scroll: Scrollset scroll to render too.
wrap: WrapWord Wrap Type. Default is Wrap::Word.
camera_type: CameraTypeCameraType used to render with.
glyph_vertices: Vec<TextVertex>Buffer used to Store Premade Glyphs. Avoids making new vec every create_quad call at risk of more memory. will only resize when resizing is needed
order_override: Option<Vec3>Overides the absolute order values based on position.
changed: boolIf anything got updated we need to update the buffers too.
Implementations§
Source§impl Text
impl Text
Sourcepub fn create_quad(
&mut self,
cache: &mut SwashCache,
atlas: &mut TextAtlas,
renderer: &mut GpuRenderer,
) -> Result<(), GraphicsError>
pub fn create_quad( &mut self, cache: &mut SwashCache, atlas: &mut TextAtlas, renderer: &mut GpuRenderer, ) -> Result<(), GraphicsError>
Updates the Text’s Buffers to prepare them for rendering.
Sourcepub fn new(
renderer: &mut GpuRenderer,
metrics: Option<Metrics>,
pos: Vec3,
size: Vec2,
scale: f32,
render_layer: u32,
) -> Self
pub fn new( renderer: &mut GpuRenderer, metrics: Option<Metrics>, pos: Vec3, size: Vec2, scale: f32, render_layer: u32, ) -> Self
Creates a new Text.
Sourcepub fn set_camera_type(&mut self, camera_type: CameraType)
pub fn set_camera_type(&mut self, camera_type: CameraType)
Sets the Text’s CameraType for rendering.
Sourcepub fn unload(&self, renderer: &mut GpuRenderer)
pub fn unload(&self, renderer: &mut GpuRenderer)
Unloads the Text from the Instance Buffers Store and its outline from the VBO Store.
Sourcepub fn set_order_override(&mut self, order_override: Option<Vec3>) -> &mut Self
pub fn set_order_override(&mut self, order_override: Option<Vec3>) -> &mut Self
Updates the Text’s order_override.
Sourcepub fn set_text(
&mut self,
renderer: &mut GpuRenderer,
text: &str,
attrs: Attrs<'_>,
shaping: Shaping,
) -> &mut Self
pub fn set_text( &mut self, renderer: &mut GpuRenderer, text: &str, attrs: Attrs<'_>, shaping: Shaping, ) -> &mut Self
Resets the Text to contain the new text only.
Sourcepub fn set_rich_text<'r, 's, I>(
&mut self,
renderer: &mut GpuRenderer,
spans: I,
default_attr: Attrs<'_>,
shaping: Shaping,
) -> &mut Self
pub fn set_rich_text<'r, 's, I>( &mut self, renderer: &mut GpuRenderer, spans: I, default_attr: Attrs<'_>, shaping: Shaping, ) -> &mut Self
Resets the Text to contain the new span of text only.
Sourcepub fn get_text_buffer(&mut self) -> &mut Buffer
pub fn get_text_buffer(&mut self) -> &mut Buffer
For more advanced shaping and usage. Use Text::set_change to set if you need it to make changes or not.
This will not set the change to true. when changes are made you must set changed to true.
Sourcepub fn shape_until_cursor(
&mut self,
renderer: &mut GpuRenderer,
cursor: Cursor,
) -> &mut Self
pub fn shape_until_cursor( &mut self, renderer: &mut GpuRenderer, cursor: Cursor, ) -> &mut Self
cursor shaping sets the Text’s location to shape from and sets the buffers scroll.
Sourcepub fn shape_until(
&mut self,
renderer: &mut GpuRenderer,
line: usize,
) -> &mut Self
pub fn shape_until( &mut self, renderer: &mut GpuRenderer, line: usize, ) -> &mut Self
cursor shaping sets the Text’s location to shape from.
Sourcepub fn shape_until_scroll(&mut self, renderer: &mut GpuRenderer) -> &mut Self
pub fn shape_until_scroll(&mut self, renderer: &mut GpuRenderer) -> &mut Self
scroll shaping sets the Text’s location to shape from.
Sourcepub fn set_scroll(
&mut self,
renderer: &mut GpuRenderer,
scroll: Scroll,
) -> &mut Self
pub fn set_scroll( &mut self, renderer: &mut GpuRenderer, scroll: Scroll, ) -> &mut Self
sets scroll for shaping and sets the Text’s location to shape from.
Sourcepub fn set_change(&mut self, changed: bool) -> &mut Self
pub fn set_change(&mut self, changed: bool) -> &mut Self
Sets the Text as changed for updating.
Sourcepub fn set_wrap(&mut self, renderer: &mut GpuRenderer, wrap: Wrap) -> &mut Self
pub fn set_wrap(&mut self, renderer: &mut GpuRenderer, wrap: Wrap) -> &mut Self
Sets the Text wrapping.
Sourcepub fn set_bounds(&mut self, bounds: Bounds) -> &mut Self
pub fn set_bounds(&mut self, bounds: Bounds) -> &mut Self
Sets the Text’s clipping bounds.
Sourcepub fn set_position(&mut self, position: Vec3) -> &mut Self
pub fn set_position(&mut self, position: Vec3) -> &mut Self
Sets the Text’s screen Posaition.
Sourcepub fn set_default_color(&mut self, color: Color) -> &mut Self
pub fn set_default_color(&mut self, color: Color) -> &mut Self
Sets the Text’s default color.
Sourcepub fn set_buffer_size(
&mut self,
renderer: &mut GpuRenderer,
width: Option<f32>,
height: Option<f32>,
) -> &mut Self
pub fn set_buffer_size( &mut self, renderer: &mut GpuRenderer, width: Option<f32>, height: Option<f32>, ) -> &mut Self
Sets the Text’s cosmic text buffer size.
Sourcepub fn clear(&mut self, renderer: &mut GpuRenderer) -> &mut Self
pub fn clear(&mut self, renderer: &mut GpuRenderer) -> &mut Self
clears the Text buffer.
Sourcepub fn update(
&mut self,
cache: &mut SwashCache,
atlas: &mut TextAtlas,
renderer: &mut GpuRenderer,
) -> Result<OrderedIndex, GraphicsError>
pub fn update( &mut self, cache: &mut SwashCache, atlas: &mut TextAtlas, renderer: &mut GpuRenderer, ) -> Result<OrderedIndex, GraphicsError>
Returns a OrderedIndex used in Rendering.
Sourcepub fn check_mouse_bounds(&self, mouse_pos: Vec2) -> bool
pub fn check_mouse_bounds(&self, mouse_pos: Vec2) -> bool
Checks if mouse_pos is within the Text’s location.
Sourcepub fn visible_details(&self) -> VisibleDetails
pub fn visible_details(&self) -> VisibleDetails
Returns Visible Width and Line details of the Rendered Text.
Sourcepub fn measure_string(
font_system: &mut FontSystem,
text: &str,
attrs: Attrs<'_>,
options: TextOptions,
) -> Vec2
pub fn measure_string( font_system: &mut FontSystem, text: &str, attrs: Attrs<'_>, options: TextOptions, ) -> Vec2
Allows measuring the String for how big it will be when Rendering. This will not create any buffers in the rendering system.
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
Blanket Implementations§
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> 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> DowncastSync for T
impl<T> DowncastSync for T
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 more