ascending_graphics

Struct Text

Source
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: Buffer

Cosmic Text Buffer.

§pos: Vec3

Position on the Screen.

§size: Vec2

Width and Height of the Text Area.

§scale: f32

Scale of the Text.

§default_color: Color

Default Text Font Color.

§bounds: Bounds

Clip Bounds of Text.

§store_id: Index

Instance Buffer Store Index of Text Buffer.

§render_layer: u32

Rendering Layer of the Text used in DrawOrder.

§order: DrawOrder

the draw order of the Text. created/updated when update is called.

§cursor: Cursor

Cursor the shaping is set too.

§line: usize

line the shaping is set too.

§scroll: Scroll

set scroll to render too.

§wrap: Wrap

Word Wrap Type. Default is Wrap::Word.

§camera_type: CameraType

CameraType 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: bool

If anything got updated we need to update the buffers too.

Implementations§

Source§

impl Text

Source

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.

Source

pub fn new( renderer: &mut GpuRenderer, metrics: Option<Metrics>, pos: Vec3, size: Vec2, scale: f32, render_layer: u32, ) -> Self

Creates a new Text.

Source

pub fn set_camera_type(&mut self, camera_type: CameraType)

Sets the Text’s CameraType for rendering.

Source

pub fn unload(&self, renderer: &mut GpuRenderer)

Unloads the Text from the Instance Buffers Store and its outline from the VBO Store.

Source

pub fn set_order_override(&mut self, order_override: Option<Vec3>) -> &mut Self

Updates the Text’s order_override.

Source

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.

Source

pub fn set_rich_text<'r, 's, I>( &mut self, renderer: &mut GpuRenderer, spans: I, default_attr: Attrs<'_>, shaping: Shaping, ) -> &mut Self
where I: IntoIterator<Item = (&'s str, Attrs<'r>)>,

Resets the Text to contain the new span of text only.

Source

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.

Source

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.

Source

pub fn shape_until( &mut self, renderer: &mut GpuRenderer, line: usize, ) -> &mut Self

cursor shaping sets the Text’s location to shape from.

Source

pub fn shape_until_scroll(&mut self, renderer: &mut GpuRenderer) -> &mut Self

scroll shaping sets the Text’s location to shape from.

Source

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.

Source

pub fn set_change(&mut self, changed: bool) -> &mut Self

Sets the Text as changed for updating.

Source

pub fn set_wrap(&mut self, renderer: &mut GpuRenderer, wrap: Wrap) -> &mut Self

Sets the Text wrapping.

Source

pub fn set_bounds(&mut self, bounds: Bounds) -> &mut Self

Sets the Text’s clipping bounds.

Source

pub fn set_position(&mut self, position: Vec3) -> &mut Self

Sets the Text’s screen Posaition.

Source

pub fn set_default_color(&mut self, color: Color) -> &mut Self

Sets the Text’s default color.

Source

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.

Source

pub fn clear(&mut self, renderer: &mut GpuRenderer) -> &mut Self

clears the Text buffer.

Source

pub fn update( &mut self, cache: &mut SwashCache, atlas: &mut TextAtlas, renderer: &mut GpuRenderer, ) -> Result<OrderedIndex, GraphicsError>

Returns a OrderedIndex used in Rendering.

Source

pub fn check_mouse_bounds(&self, mouse_pos: Vec2) -> bool

Checks if mouse_pos is within the Text’s location.

Source

pub fn visible_details(&self) -> VisibleDetails

Returns Visible Width and Line details of the Rendered Text.

Source

pub fn measure(&self) -> Vec2

measure’s the Text’s Rendering Size.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,