Skip to main content

Glyphs

Struct Glyphs 

Source
pub struct Glyphs {
    shaper: Shaper,
    outlines: Outlines,
    inked: RefCell<HashMap<GlyphId, Option<Path2d>>>,
}
Expand description

A typeface as the canvas draws it: the Shaper the kernel is called with, and a Path2d per glyph traced from the same face’s outlines.

Fields§

§shaper: Shaper§outlines: Outlines§inked: RefCell<HashMap<GlyphId, Option<Path2d>>>

Glyphs already traced into the browser’s own path type. None where the glyph draws nothing, so a space is looked up rather than retraced.

Implementations§

Source§

impl Glyphs

Source

pub fn new(typeface: FontChoice) -> Self

Source

pub fn metrics(&self) -> Metrics

The vertical metrics both halves are stated in.

Source

pub fn glyph_index(&self, chr: char) -> Option<GlyphId>

The glyph a face’s character map files chr under — the identity a layout that carries none falls back to.

Source

pub fn path(&self, id: GlyphId) -> Option<Path2d>

id’s ink as a path in font units, Y up, or None where the glyph draws nothing.

Trait Implementations§

Source§

impl TextLayout for Glyphs

Source§

fn typeface(&self) -> FontChoice

The typeface this engine lays text out in. The SVG export traces its outlines from that face’s own bytes, so an engine that answered for a different one would place one font’s glyphs at another’s pen positions.
Source§

fn layout(&self, text: &str, font: &Font, wrap: WorldPx) -> Layout

Lay text out in font, word-wrapped at wrap (WorldPx::UNBOUNDED for an unwrapped run). An exporter’s engine lays out at one pixel per point, so a resolution-independent format inherits no display’s DPI; the screen’s lays out at the display’s, so a mark recorded through it lands where the screen draws it.

Auto Trait Implementations§

§

impl !Freeze for Glyphs

§

impl !RefUnwindSafe for Glyphs

§

impl Send for Glyphs

§

impl !Sync for Glyphs

§

impl Unpin for Glyphs

§

impl UnsafeUnpin for Glyphs

§

impl UnwindSafe for Glyphs

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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, 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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