Skip to main content

DFont

Struct DFont 

Source
pub struct DFont {
    pub backing: Vec<u8>,
    pub location: Vec<VariationSetting>,
    pub normalized_location: Location,
    pub codepoints: HashSet<u32>,
}
Expand description

A representation of everything we need to know about a font for diffenator purposes

Fields§

§backing: Vec<u8>

The font binary data

§location: Vec<VariationSetting>

The location of the font we are interested in diffing

§normalized_location: Location

The normalized location of the font

§codepoints: HashSet<u32>

The set of encoded codepoints in the font

Implementations§

Source§

impl DFont

Source

pub fn new(string: &[u8]) -> Self

Create a new DFont from a byte slice

Source

pub fn normalize_location(&mut self)

Normalize the location

This method must be called after the location is changed. (It’s that or getters and setters, and nobody wants that.)

Source

pub fn set_location(&mut self, variations: &str) -> Result<(), String>

Set the location of the font given a user-specified location string

Source

pub fn instances(&self) -> Vec<String>

The names of the font’s named instances

Source

pub fn set_instance(&mut self, instance: &str) -> Result<(), String>

Set the location of the font to a given named instance

Source

pub fn fontref(&self) -> FontRef<'_>

Source

pub fn family_name(&self) -> String

Source

pub fn style_name(&self) -> String

Source

pub fn axis_info(&self) -> HashMap<String, (f32, f32, f32)>

The axes of the font

Returns a map from axis tag to (min, default, max) values

Source

pub fn supported_scripts(&self) -> HashSet<String>

Returns a list of scripts where the font has at least one encoded character from that script.

Source

pub fn masters(&self) -> Result<Vec<Vec<VariationSetting>>, ReadError>

Returns a list of the master locations in the font

This is derived heuristically from locations of shared tuples in the gvar table. This should work well enough for most “normal” fonts.

Trait Implementations§

Source§

impl Clone for DFont

Source§

fn clone(&self) -> DFont

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 DFont

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for DFont

§

impl RefUnwindSafe for DFont

§

impl Send for DFont

§

impl Sync for DFont

§

impl Unpin for DFont

§

impl UnsafeUnpin for DFont

§

impl UnwindSafe for DFont

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.