YaffFont

Struct YaffFont 

Source
pub struct YaffFont {
Show 63 fields pub yaff_version: Option<String>, pub name: Option<String>, pub family: Option<String>, pub subfamily: Option<String>, pub revision: Option<String>, pub point_size: Option<f32>, pub line_height: Option<i32>, pub style: Option<String>, pub weight: Option<String>, pub slant: Option<String>, pub setwidth: Option<String>, pub decoration: Option<String>, pub x_height: Option<i32>, pub cap_height: Option<i32>, pub ascent: Option<i32>, pub descent: Option<i32>, pub pixel_size: Option<i32>, pub leading: Option<i32>, pub raster_bounds: Option<(i32, i32, i32, i32)>, pub ink_bounds: Option<(i32, i32, i32, i32)>, pub raster_size: Option<(u32, u32)>, pub cell_size: Option<(u32, u32)>, pub bounding_box: Option<(u32, u32)>, pub average_width: Option<f32>, pub max_width: Option<i32>, pub cap_width: Option<i32>, pub digit_width: Option<i32>, pub spacing: Option<FontSpacing>, pub direction: Option<WritingDirection>, pub bold_smear: Option<i32>, pub italic_pitch: Option<(i32, i32)>, pub outline_thickness: Option<i32>, pub underline_thickness: Option<i32>, pub underline_descent: Option<i32>, pub strikethrough_thickness: Option<i32>, pub strikethrough_ascent: Option<i32>, pub superscript_size: Option<i32>, pub superscript_offset: Option<(i32, i32)>, pub subscript_size: Option<i32>, pub subscript_offset: Option<(i32, i32)>, pub small_cap_size: Option<i32>, pub word_space: Option<i32>, pub min_word_space: Option<i32>, pub max_word_space: Option<i32>, pub sentence_space: Option<i32>, pub author: Option<String>, pub foundry: Option<String>, pub copyright: Option<String>, pub notice: Option<String>, pub device: Option<String>, pub pixel_aspect: Option<(u32, u32)>, pub dpi: Option<(u32, u32)>, pub converter: Option<String>, pub source_name: Option<String>, pub source_format: Option<String>, pub history: Option<String>, pub encoding: Option<String>, pub default_char_label_raw: Option<String>, pub word_boundary_label_raw: Option<String>, pub global_left_bearing: Option<i32>, pub global_right_bearing: Option<i32>, pub global_shift_up: Option<i32>, pub glyphs: Vec<GlyphDefinition>,
}

Fields§

§yaff_version: Option<String>§name: Option<String>§family: Option<String>§subfamily: Option<String>§revision: Option<String>§point_size: Option<f32>§line_height: Option<i32>§style: Option<String>§weight: Option<String>§slant: Option<String>§setwidth: Option<String>§decoration: Option<String>§x_height: Option<i32>§cap_height: Option<i32>§ascent: Option<i32>§descent: Option<i32>§pixel_size: Option<i32>§leading: Option<i32>§raster_bounds: Option<(i32, i32, i32, i32)>§ink_bounds: Option<(i32, i32, i32, i32)>§raster_size: Option<(u32, u32)>§cell_size: Option<(u32, u32)>§bounding_box: Option<(u32, u32)>§average_width: Option<f32>§max_width: Option<i32>§cap_width: Option<i32>§digit_width: Option<i32>§spacing: Option<FontSpacing>§direction: Option<WritingDirection>§bold_smear: Option<i32>§italic_pitch: Option<(i32, i32)>§outline_thickness: Option<i32>§underline_thickness: Option<i32>§underline_descent: Option<i32>§strikethrough_thickness: Option<i32>§strikethrough_ascent: Option<i32>§superscript_size: Option<i32>§superscript_offset: Option<(i32, i32)>§subscript_size: Option<i32>§subscript_offset: Option<(i32, i32)>§small_cap_size: Option<i32>§word_space: Option<i32>§min_word_space: Option<i32>§max_word_space: Option<i32>§sentence_space: Option<i32>§author: Option<String>§foundry: Option<String>§copyright: Option<String>§notice: Option<String>§device: Option<String>§pixel_aspect: Option<(u32, u32)>§dpi: Option<(u32, u32)>§converter: Option<String>§source_name: Option<String>§source_format: Option<String>§history: Option<String>§encoding: Option<String>§default_char_label_raw: Option<String>§word_boundary_label_raw: Option<String>§global_left_bearing: Option<i32>§global_right_bearing: Option<i32>§global_shift_up: Option<i32>§glyphs: Vec<GlyphDefinition>

Implementations§

Source§

impl YaffFont

Source

pub fn new() -> Self

Source§

impl YaffFont

Source

pub fn from_reader<R: Read>(reader: R) -> Result<YaffFont, ParseError>

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, ParseError>

Examples found in repository?
examples/test.rs (line 11)
3fn main() {
4    let path_in = std::env::args()
5        .nth(1)
6        .expect("Please provide an input file path as the first argument");
7    let path_out = std::env::args()
8        .nth(2)
9        .expect("Please provide an output file path as the second argument");
10    let path_in2 = path_in.clone();
11    match YaffFont::from_path(path_in) {
12        Ok(font) => {
13            let yaff_string = to_yaff_string(&font);
14            std::fs::write(path_out, yaff_string).expect("Unable to write file");
15        }
16        Err(e) => {
17            eprintln!("Failed to parse YAFF data from file {}: {:?}", path_in2, e);
18            std::process::exit(1);
19        }
20    }
21}

Trait Implementations§

Source§

impl Clone for YaffFont

Source§

fn clone(&self) -> YaffFont

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 YaffFont

Source§

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

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

impl Default for YaffFont

Source§

fn default() -> YaffFont

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

impl FromStr for YaffFont

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for YaffFont

Source§

fn eq(&self, other: &YaffFont) -> 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 StructuralPartialEq for YaffFont

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