Skip to main content

FontModifier

Struct FontModifier 

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

Font modifier for updating font properties.

Provides a builder-style API for modifying font metadata, metrics, and other properties. Changes are tracked internally and applied when commit() is called.

§Note

Full round-trip serialization with proper offset recalculation is currently in development. Some modifications may not persist correctly when saving and reloading the font.

Implementations§

Source§

impl FontModifier

Source

pub fn new(font: Font) -> Self

Source

pub fn set_font_name(&mut self, name: &str) -> Result<&mut Self>

Set font family name (name ID 1).

Updates the font family name in the name table.

§Arguments
  • name - The new font family name
§Examples
let font = Font::load("font.ttf")?;
let mut modifier = font.modify();
modifier.set_font_name("My Font Family")?;
Source

pub fn set_full_font_name(&mut self, name: &str) -> Result<&mut Self>

Set full font name (name ID 4).

Updates the full font name (family + style) in the name table.

§Arguments
  • name - The new full font name
Source

pub fn set_version(&mut self, major: u16, minor: u16) -> Result<&mut Self>

Set version string (name ID 5).

Updates the version string in the name table and font revision in head table.

§Arguments
  • major - Major version number
  • minor - Minor version number
§Examples
let font = Font::load("font.ttf")?;
let mut modifier = font.modify();
modifier.set_version(2, 0)?;

Set copyright notice (name ID 0).

Updates the copyright notice in the name table.

§Arguments
  • copyright - The copyright notice text
Source

pub fn set_trademark(&mut self, trademark: &str) -> Result<&mut Self>

Set trademark notice (name ID 7).

Updates the trademark notice in the name table.

§Arguments
  • trademark - The trademark notice text
Source

pub fn set_font_revision(&mut self, major: u16, minor: u16) -> Result<&mut Self>

Update font version and revision in head table.

Sets the font revision number in the head table.

§Arguments
  • major - Major version number
  • minor - Minor version number (0-99)
Source

pub fn set_embedding_type(&mut self, embedding_type: u16) -> Result<&mut Self>

Modify embedding permissions in OS/2 table

Source

pub fn set_localized_font_name( &mut self, name: &str, language_id: u16, ) -> Result<&mut Self>

Set font name in multiple languages

Source

pub fn set_font_metrics( &mut self, units_per_em: u16, ascender: i16, descender: i16, line_gap: i16, ) -> Result<&mut Self>

Update font metrics in head and hhea tables

Source

pub fn set_glyph_advance( &mut self, glyph_index: usize, advance_width: u16, ) -> Result<&mut Self>

Modify glyph advance widths

Source

pub fn commit(self) -> Result<Font>

Commit all modifications and return the modified font

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