Skip to main content

Kerning

Struct Kerning 

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

Parsed GPOS kern-feature pair positioning for a font.

Built once via Font::gpos_kerning; Kerning::pair is a cheap, allocation-free lookup. An empty Kerning (no GPOS / no kern feature / malformed) makes every pair() return 0.

Implementations§

Source§

impl Kerning

Source

pub fn pair(&self, left: u16, right: u16) -> i16

x-advance adjustment (font design units) applied between left and right glyph ids; 0 if no kern pair applies. First matching subtable wins.

Source

pub fn for_each_ascii_pair( &self, glyph_of: impl Fn(u8) -> u16, emit: impl FnMut(u8, u8, i16), )

Enumerates the ASCII byte pairs this kerning adjusts, replacing the 16,384-pair brute force over Kerning::pair.

For every byte pair (l, r) with pair(glyph_of(l), glyph_of(r)) != 0 — where glyph_of maps the 128 ASCII bytes to glyph ids, possibly several bytes to one glyph — calls emit(l, r, v) with v exactly equal to that pair result (first matching subtable wins, defined zeros shadow later subtables just like pair). Pairs resolving to 0 are never emitted: a zero-initialized matrix already holds their value, so emit fires once per nonzero cell. The order of emit calls across distinct pairs is unspecified (format-1 pair maps hash-scatter), so emit must be order-independent.

Cost is proportional to what the tables actually contain — format-1 pair-map entries and format-2 coverage glyphs — instead of the full 128x128 cross product.

Trait Implementations§

Source§

impl Clone for Kerning

Source§

fn clone(&self) -> Self

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 Debug for Kerning

Source§

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

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

impl Default for Kerning

Source§

fn default() -> Self

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

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.