Skip to main content

Text

Struct Text 

Source
pub struct Text {
    pub color: [f64; 3],
    /* private fields */
}
Expand description

A text member — a port of lib3’s Text. See the module doc for how this differs from the JS Object3D subclass it ports.

Fields§

§color: [f64; 3]

Member colour, linear, default white. See the module doc.

Implementations§

Source§

impl Text

Source

pub fn new() -> Self

new Text() — every layout property at its LAYOUT_DEFAULTS value, and _needsSync = true, so the first sync always lays out.

Source

pub fn text(&self) -> &str

The string to lay out.

Source

pub fn set_text(&mut self, value: impl Into<String>)

Sets the string to lay out — text.text = value.

Source

pub fn font_size(&self) -> f64

Font size, world units.

Source

pub fn set_font_size(&mut self, value: f64)

Sets the font size — text.fontSize = value.

Source

pub fn font_family(&self) -> &str

CSS font family. Canvas layout only; vector layout never reads it.

Source

pub fn set_font_family(&mut self, value: impl Into<String>)

Sets the CSS font family — text.fontFamily = value.

Source

pub fn font_weight(&self) -> &str

CSS font weight. Canvas layout only.

Source

pub fn set_font_weight(&mut self, value: impl Into<String>)

Sets the CSS font weight — text.fontWeight = value.

Source

pub fn font_style(&self) -> &str

CSS font style. Canvas layout only.

Source

pub fn set_font_style(&mut self, value: impl Into<String>)

Sets the CSS font style — text.fontStyle = value.

Source

pub fn letter_spacing(&self) -> f64

Extra space added per glyph. See the module’s asymmetric-spacing note.

Source

pub fn set_letter_spacing(&mut self, value: f64)

Sets the letter spacing — text.letterSpacing = value.

Source

pub fn line_height(&self) -> LineHeight

Line height, as LineHeight.

Source

pub fn set_line_height(&mut self, value: LineHeight)

Sets the line height — text.lineHeight = value.

Source

pub fn anchor_x(&self) -> &Anchor

Horizontal anchor.

Source

pub fn set_anchor_x(&mut self, value: Anchor)

Sets the horizontal anchor — text.anchorX = value.

Source

pub fn anchor_y(&self) -> &Anchor

Vertical anchor.

Source

pub fn set_anchor_y(&mut self, value: Anchor)

Sets the vertical anchor — text.anchorY = value.

Source

pub fn text_align(&self) -> TextAlign

Multi-line alignment.

Source

pub fn set_text_align(&mut self, value: TextAlign)

Sets the text alignment — text.textAlign = value.

Source

pub fn max_width(&self) -> f64

Line-wrap width, world units. f64::INFINITY by default (no wrap).

Source

pub fn set_max_width(&mut self, value: f64)

Sets the line-wrap width — text.maxWidth = value.

Source

pub fn text_render_info(&self) -> Option<&TextRenderInfo>

The most recent layout, or None before the first Text::sync.

Source

pub fn opacity(&self) -> f64

Whole-text opacity (0..1).

Source

pub fn set_opacity(&mut self, value: f64)

Does not trigger re-layout; writes through to the owning batch’s per-glyph opacity attribute when batched.

Source

pub fn member_id(&self) -> Option<usize>

None when the member has not joined a batch (-1 in the JS).

Source

pub fn set_vector_mode(&mut self, on: bool)

_vectorMode / _vectorFont. Passing None for the font while the mode is on is the “still loading” state sync has a branch for.

Source

pub fn vector_mode(&self) -> bool

Whether vector-outline layout is on.

Source

pub fn set_vector_font(&mut self, font: Option<Rc<VectorFont>>)

_vectorFont, set by the owning BatchedText.

Source

pub fn sync(&mut self) -> &TextRenderInfo

sync(callback, renderer) — lay out the glyphs, unless a cached layout is still valid.

The callback is a JS idiom for “the layout may be asynchronous”; it never is, so it is dropped. The renderer argument was already unused in the JS.

Note the vector-mode-without-a-font branch: it installs an empty layout and returns without clearing the dirty flag, so the next sync after the font arrives re-lays out. It also does not touch layouts_performed, because no layout happened.

Trait Implementations§

Source§

impl Default for Text

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Text

§

impl !Send for Text

§

impl !Sync for Text

§

impl !UnwindSafe for Text

§

impl Freeze for Text

§

impl Unpin for Text

§

impl UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.