SimpleGlyph

Struct SimpleGlyph 

Source
pub struct SimpleGlyph {
    pub bbox: Bbox,
    pub contours: Vec<Contour>,
    pub instructions: Vec<u8>,
}
Expand description

A simple (without components) glyph

Fields§

§bbox: Bbox§contours: Vec<Contour>§instructions: Vec<u8>

Implementations§

Source§

impl SimpleGlyph

Source

pub fn from_bezpath(path: &BezPath) -> Result<Self, MalformedPath>

Attempt to create a simple glyph from a kurbo BezPath

The path may contain only line and quadratic bezier segments. The caller is responsible for converting any cubic segments to quadratics before calling.

Returns an error if the input path is malformed; that is, if it is empty, contains cubic segments, or does not begin with a ‘move’ instruction.

Context

  • In the glyf table simple (contour based) glyph paths implicitly close when rendering.
  • In font sources, and svg, open and closed paths are distinct.
  • An explicit closePath joins the first/last points of a contour
    • This is not the same as ending with some other drawing command whose endpoint is the contour startpoint
  • In FontTools endPath says I’m done with this subpath, BezPath has no endPath.

Context courtesy of @anthrotype.

Source

pub fn interpolatable_glyphs_from_bezpaths( paths: &[BezPath], ) -> Result<Vec<Self>, MalformedPath>

Attempt to create a set of interpolation-compatible glyphs from a set of paths.

The paths are expected to be preprocessed, and interpolation compatible (i.e. they should have the same number and type of points, in the same order.) They should contain only line and quadratic segments; the caller is responsible for converting cubics to quadratics as needed.

This method is provided for use when compiling variable fonts. The inputs are expected to be different instances of the same named glyph, each corresponding to a different location in the variation space.

Source

pub fn recompute_bounding_box(&mut self)

Recompute the Glyph’s bounding box based on the current contours

Trait Implementations§

Source§

impl Clone for SimpleGlyph

Source§

fn clone(&self) -> SimpleGlyph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SimpleGlyph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SimpleGlyph

Source§

fn default() -> SimpleGlyph

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

impl<'a> FontRead<'a> for SimpleGlyph

Source§

fn read(data: FontData<'a>) -> Result<Self, ReadError>

Read an instance of Self from the provided data, performing validation. Read more
Source§

impl FontWrite for SimpleGlyph

Source§

fn write_into(&self, writer: &mut TableWriter)

Write our data and information about offsets into this TableWriter.
Source§

fn table_type(&self) -> TableType

The type of this table. Read more
Source§

impl From<SimpleGlyph> for Glyph

Source§

fn from(value: SimpleGlyph) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for SimpleGlyph

Source§

fn eq(&self, other: &SimpleGlyph) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Validate for SimpleGlyph

Source§

fn validate_impl(&self, ctx: &mut ValidationCtx)

Validate this table. Read more
Source§

fn validate(&self) -> Result<(), ValidationReport>

Ensure that this table is well-formed, reporting any errors. Read more
Source§

impl Eq for SimpleGlyph

Source§

impl SomeGlyph for SimpleGlyph

Source§

impl StructuralPartialEq for SimpleGlyph

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<'a, T> FontReadWithArgs<'a> for T
where T: FontRead<'a>,

Source§

fn read_with_args( data: FontData<'a>, _: &<T as ReadArgs>::Args, ) -> Result<T, ReadError>

read an item, using the provided args. Read more
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<'a, T> ReadArgs for T
where T: FontRead<'a>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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.