Skip to main content

Shaper

Struct Shaper 

Source
pub struct Shaper {
    typeface: FontChoice,
    metrics: Metrics,
    font: FontRef<'static>,
    data: ShaperData,
    laid_out: RefCell<LayoutCache>,
}
Expand description

One typeface, shaped by harfrust and broken into rows by the desktop engine’s rules — the whole of what TextLayout asks of a host, with no toolkit under it.

Fields§

§typeface: FontChoice§metrics: Metrics§font: FontRef<'static>§data: ShaperData

The parsed layout tables. Cached per face, as a layout engine caches them: building a shaper from them is cheap, parsing them is not.

§laid_out: RefCell<LayoutCache>

Implementations§

Source§

impl Shaper

Source

pub fn new(typeface: FontChoice) -> Self

§Panics

If the typeface’s embedded bytes are not a font this can read.

Source

pub fn metrics(&self) -> Metrics

The metrics this engine measures a row by.

Source

pub fn glyph_ids(&self, text: &str) -> Vec<GlyphId>

The glyphs one paragraph of text shapes to, in visual order — identity only, for a consumer that has the positions already.

Source

fn shape(&self, text: &str) -> Vec<Shaped>

Trait Implementations§

Source§

impl TextLayout for Shaper

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 Shaper

§

impl !RefUnwindSafe for Shaper

§

impl Send for Shaper

§

impl !Sync for Shaper

§

impl Unpin for Shaper

§

impl UnsafeUnpin for Shaper

§

impl UnwindSafe for Shaper

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

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