Skip to main content

KernedFont

Struct KernedFont 

Source
pub struct KernedFont { /* private fields */ }
Expand description

A face paired with the pair kerning ab_glyph cannot read for itself.

This is a Font rather than a lookup the call sites reach for, because there are nine of them across measuring, line breaking, alignment and drawing, several behind impl Font generics that never see a SoftwareTextFont. Overriding kern_unscaled puts the rule under every existing scaled_font.kern(..) at once — including any this change did not go looking for — and keeps a caller from having to remember which width is the kerned one.

Implementations§

Source§

impl KernedFont

Source

pub fn new(font: FontArc, kerning: Option<Arc<GposKerning>>) -> Self

Source

pub fn read_kerning( bytes: &[u8], variations: &[([u8; 4], f32)], ) -> Option<Arc<GposKerning>>

Reads the GPOS pair kerning for a face instanced at variations.

variations are the (tag, user value) pairs actually applied to the face, in the same units the caller handed set_variation; normalizing them is ttf_parser’s job and doing it a second way here would be a second answer.

Trait Implementations§

Source§

impl Clone for KernedFont

Source§

fn clone(&self) -> KernedFont

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Font for KernedFont

Source§

fn units_per_em(&self) -> Option<f32>

Get the size of the font unit Read more
Source§

fn ascent_unscaled(&self) -> f32

Unscaled glyph ascent. See glyph layout concepts. Read more
Source§

fn descent_unscaled(&self) -> f32

Unscaled glyph descent. See glyph layout concepts. Read more
Source§

fn line_gap_unscaled(&self) -> f32

Unscaled line gap. See glyph layout concepts. Read more
Source§

fn italic_angle(&self) -> f32

The slant angle of the font. Read more
Source§

fn glyph_id(&self, c: char) -> GlyphId

Lookup a GlyphId matching a given char. Read more
Source§

fn h_advance_unscaled(&self, id: GlyphId) -> f32

Unscaled horizontal advance for a given glyph id. See glyph layout concepts. Read more
Source§

fn h_side_bearing_unscaled(&self, id: GlyphId) -> f32

Unscaled horizontal side bearing for a given glyph id. See glyph layout concepts. Read more
Source§

fn v_advance_unscaled(&self, id: GlyphId) -> f32

Unscaled vertical advance for a given glyph id. Read more
Source§

fn v_side_bearing_unscaled(&self, id: GlyphId) -> f32

Unscaled vertical side bearing for a given glyph id. Read more
Source§

fn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32

Returns additional unscaled kerning to apply for a particular pair of glyph ids. Read more
Source§

fn outline(&self, id: GlyphId) -> Option<Outline>

Compute unscaled glyph outline curves & bounding box.
Source§

fn glyph_count(&self) -> usize

The number of glyphs present in this font. Glyph identifiers for this font will always be in the range 0..self.glyph_count()
Source§

fn codepoint_ids(&self) -> CodepointIdIter<'_>

Returns an iterator of all distinct (GlyphId, char) pairs. Not ordered. Read more
Source§

fn glyph_raster_image2( &self, id: GlyphId, pixel_size: u16, ) -> Option<GlyphImage<'_>>

Returns a pre-rendered image of the glyph. Read more
Source§

fn glyph_svg_image(&self, id: GlyphId) -> Option<GlyphSvg<'_>>

Returns raw SVG data of a range of glyphs which includes this one. Read more
Source§

fn font_data(&self) -> &[u8]

Extracts a slice containing the data passed into e.g. FontArc::try_from_slice. Read more
Source§

fn pt_to_px_scale(&self, pt_size: f32) -> Option<PxScale>

Converts pt units into PxScale. Read more
Source§

fn height_unscaled(&self) -> f32

Unscaled height ascent - descent. See glyph layout concepts. Read more
Source§

fn glyph_raster_image( &self, id: GlyphId, pixel_size: u16, ) -> Option<GlyphImage<'_>>

👎Deprecated since 0.2.22:

Deprecated in favor of glyph_raster_image2

Returns a pre-rendered image of the glyph. Read more
Source§

fn glyph_bounds(&self, glyph: &Glyph) -> Rect
where Self: Sized,

Returns the layout bounds of this glyph. Read more
Source§

fn outline_glyph(&self, glyph: Glyph) -> Option<OutlinedGlyph>
where Self: Sized,

Compute glyph outline ready for drawing.
Source§

fn as_scaled<S>(&self, scale: S) -> PxScaleFont<&Self>
where S: Into<PxScale>, Self: Sized,

Construct a PxScaleFont by associating with the given pixel scale. Read more
Source§

fn into_scaled<S>(self, scale: S) -> PxScaleFont<Self>
where S: Into<PxScale>, Self: Sized,

Move into a PxScaleFont associated with the given pixel scale.

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