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
impl SimpleGlyph
Sourcepub fn from_bezpath(path: &BezPath) -> Result<Self, MalformedPath>
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.
- In SVG closure matters due to influence on strokes, https://www.w3.org/TR/SVG11/paths.html#PathDataClosePathCommand.
- 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.
Sourcepub fn interpolatable_glyphs_from_bezpaths(
paths: &[BezPath],
) -> Result<Vec<Self>, MalformedPath>
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.
Sourcepub fn recompute_bounding_box(&mut self)
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
impl Clone for SimpleGlyph
Source§fn clone(&self) -> SimpleGlyph
fn clone(&self) -> SimpleGlyph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SimpleGlyph
impl Debug for SimpleGlyph
Source§impl Default for SimpleGlyph
impl Default for SimpleGlyph
Source§fn default() -> SimpleGlyph
fn default() -> SimpleGlyph
Source§impl<'a> FontRead<'a> for SimpleGlyph
impl<'a> FontRead<'a> for SimpleGlyph
Source§impl FontWrite for SimpleGlyph
impl FontWrite for SimpleGlyph
Source§fn write_into(&self, writer: &mut TableWriter)
fn write_into(&self, writer: &mut TableWriter)
Source§fn table_type(&self) -> TableType
fn table_type(&self) -> TableType
Source§impl From<SimpleGlyph> for Glyph
impl From<SimpleGlyph> for Glyph
Source§fn from(value: SimpleGlyph) -> Self
fn from(value: SimpleGlyph) -> Self
Source§impl PartialEq for SimpleGlyph
impl PartialEq for SimpleGlyph
Source§impl Validate for SimpleGlyph
impl Validate for SimpleGlyph
Source§fn validate_impl(&self, ctx: &mut ValidationCtx)
fn validate_impl(&self, ctx: &mut ValidationCtx)
impl Eq for SimpleGlyph
impl SomeGlyph for SimpleGlyph
impl StructuralPartialEq for SimpleGlyph
Auto Trait Implementations§
impl Freeze for SimpleGlyph
impl RefUnwindSafe for SimpleGlyph
impl Send for SimpleGlyph
impl Sync for SimpleGlyph
impl Unpin for SimpleGlyph
impl UnwindSafe for SimpleGlyph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<'a, T> FontReadWithArgs<'a> for Twhere
T: FontRead<'a>,
impl<'a, T> FontReadWithArgs<'a> for Twhere
T: FontRead<'a>,
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T
, using the provided data to resolve any offsets.