⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

TtfParser

Struct TtfParser 

Source
pub struct TtfParser<'a> { /* private fields */ }
Expand description

TrueType font parser.

Parses the font directory and individual tables from raw TTF data. Does not own the font data; operates on borrowed slices.

Implementations§

Source§

impl<'a> TtfParser<'a>

Source

pub fn new(data: &'a [u8]) -> Result<Self, FontError>

Create a new parser from raw TTF data.

Source

pub fn find_table(&self, tag: TableTag) -> Option<TableEntry>

Find a table by tag.

Source

pub fn table_data(&self, entry: &TableEntry) -> Result<&'a [u8], FontError>

Get the raw bytes for a table.

Source

pub fn parse_head(&self) -> Result<HeadTable, FontError>

Parse the head table.

Source

pub fn parse_hhea(&self) -> Result<HheaTable, FontError>

Parse the hhea table.

Source

pub fn parse_maxp(&self) -> Result<MaxpTable, FontError>

Parse the maxp table.

Source

pub fn char_to_glyph(&self, ch: u32) -> Result<u16, FontError>

Look up a glyph index from a character code using cmap table. Supports format 4 (BMP) cmap subtable.

Source

pub fn glyph_offset( &self, glyph_id: u16, head: &HeadTable, ) -> Result<(u32, u32), FontError>

Get glyph offset from loca table.

Source

pub fn parse_glyph(&self, glyph_id: u16) -> Result<GlyphOutline, FontError>

Parse a simple glyph outline from the glyf table.

Trait Implementations§

Source§

impl<'a> Debug for TtfParser<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TtfParser<'a>

§

impl<'a> RefUnwindSafe for TtfParser<'a>

§

impl<'a> Send for TtfParser<'a>

§

impl<'a> Sync for TtfParser<'a>

§

impl<'a> Unpin for TtfParser<'a>

§

impl<'a> UnwindSafe for TtfParser<'a>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.