Skip to main content

Parser

Struct Parser 

Source
struct Parser<'a> {
    data: &'a [u8],
    pos: usize,
}

Fields§

§data: &'a [u8]§pos: usize

Implementations§

Source§

impl<'a> Parser<'a>

Source

fn new(data: &'a [u8]) -> Self

Source

fn next(&mut self) -> Option<Token<'a>>

Source

fn peek(&self) -> Option<Token<'a>>

Source

fn accept(&mut self, token: Token<'_>) -> bool

Source

fn expect(&mut self, token: Token<'_>) -> Option<()>

Source

fn next_byte(&mut self) -> Option<u8>

Source

fn peek_byte(&self) -> Option<u8>

Source

fn read_bytes(&mut self, len: usize) -> Option<&'a [u8]>

Source

fn skip_whitespace(&mut self) -> Option<()>

Source

fn skip_line(&mut self)

Source

fn skip_until(&mut self, f: impl Fn(u8) -> bool) -> usize

Source

fn read_proc(&mut self, start: usize) -> Option<Token<'a>>

Source

fn read_lit_string(&mut self, start: usize) -> Option<Token<'a>>

Source

fn read_hex_string(&mut self, start: usize) -> Option<Token<'a>>

Source

fn read_int(&mut self) -> Option<i64>

Source

fn read_num_as_int(&mut self) -> Option<i32>

Source

fn read_string(&mut self) -> Option<String>

Source§

impl Parser<'_>

Source

fn read_font_matrix(&mut self) -> Option<ScaledFontMatrix>

Parse a font matrix.

Like FreeType, this is designed assuming a upem of 1000 and produces an identity matrix in that case. This is, the result is scaled such that 0.001 yields a value of 1.0.

See https://gitlab.freedesktop.org/freetype/freetype/-/blob/80a507a6b8e3d2906ad2c8ba69329bd2fb2a85ef/src/type1/t1load.c#L1403

Source

fn read_subrs(&mut self, len_iv: i64) -> Option<Subrs>

Parse the set of subroutines.

The len_iv parameter defines the number of prefix padding bytes for encrypted data. If < 0, then the data is not encrypted.

See https://gitlab.freedesktop.org/freetype/freetype/-/blob/80a507a6b8e3d2906ad2c8ba69329bd2fb2a85ef/src/type1/t1load.c#L1720

Source

fn read_charstrings(&mut self, len_iv: i64) -> Option<Charstrings>

Parse the set of charstrings.

The len_iv parameter defines the number of prefix padding bytes for encrypted data. If < 0, then the data is not encrypted.

See https://gitlab.freedesktop.org/freetype/freetype/-/blob/80a507a6b8e3d2906ad2c8ba69329bd2fb2a85ef/src/type1/t1load.c#L1919

Source

fn read_font_bbox(&mut self) -> Option<[Fixed; 4]>

Source

fn read_weight_vector(&mut self) -> Option<Vec<Fixed>>

Source

fn read_encoding(&mut self, charstrings: &Charstrings) -> Option<RawEncoding>

Source

fn read_dense_encoding(&mut self, f: impl FnMut(i64, &str)) -> Option<()>

Returns a custom encoding defined by an array of /<name>, where the index represents the character code, and invokes the given callback for each.

Source

fn read_sparse_encoding(&mut self, f: impl FnMut(i64, &str)) -> Option<()>

Reads a custom encoding defined by a map of <charcode> /<name> and invokes the given callback for each.

Trait Implementations§

Source§

impl<'a> Clone for Parser<'a>

Source§

fn clone(&self) -> Parser<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnsafeUnpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

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.