pub struct CustomFont {
pub name: String,
pub font_type: FontType,
pub encoding: FontEncoding,
pub descriptor: FontDescriptor,
pub metrics: FontMetrics,
pub font_data: Option<Vec<u8>>,
pub font_file_type: Option<FontFileType>,
pub truetype_font: Option<TrueTypeFont>,
pub used_glyphs: HashSet<u16>,
}Expand description
Represents a custom font (Type 1 or TrueType)
Fields§
§name: StringFont name
font_type: FontTypeFont type
encoding: FontEncodingFont encoding
descriptor: FontDescriptorFont descriptor
metrics: FontMetricsFont metrics
font_data: Option<Vec<u8>>Font data (for embedding)
font_file_type: Option<FontFileType>Font file type for embedding
truetype_font: Option<TrueTypeFont>Parsed TrueType font (for subsetting)
used_glyphs: HashSet<u16>Used glyphs for subsetting
Implementations§
Source§impl CustomFont
impl CustomFont
Sourcepub fn new_type1(
name: String,
encoding: FontEncoding,
descriptor: FontDescriptor,
metrics: FontMetrics,
) -> Self
pub fn new_type1( name: String, encoding: FontEncoding, descriptor: FontDescriptor, metrics: FontMetrics, ) -> Self
Create a new Type 1 font
Sourcepub fn new_truetype(
name: String,
encoding: FontEncoding,
descriptor: FontDescriptor,
metrics: FontMetrics,
) -> Self
pub fn new_truetype( name: String, encoding: FontEncoding, descriptor: FontDescriptor, metrics: FontMetrics, ) -> Self
Create a new TrueType font
Sourcepub fn optimize_for_text(&mut self, text: &str)
pub fn optimize_for_text(&mut self, text: &str)
Optimize the font for the given text content
Sourcepub fn get_glyph_mapping(&self) -> Option<HashMap<u32, u16>>
pub fn get_glyph_mapping(&self) -> Option<HashMap<u32, u16>>
Get the glyph mapping (Unicode -> GlyphID) from the font’s cmap table
Sourcepub fn load_font_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn load_font_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Load font data from file for embedding
Sourcepub fn load_truetype_font<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_truetype_font<P: AsRef<Path>>(path: P) -> Result<Self>
Load TrueType font from file
Sourcepub fn mark_characters_used(&mut self, text: &str)
pub fn mark_characters_used(&mut self, text: &str)
Mark characters as used for subsetting
Sourcepub fn to_pdf_dict(&self) -> Dictionary
pub fn to_pdf_dict(&self) -> Dictionary
Convert to PDF font dictionary
Trait Implementations§
Source§impl Clone for CustomFont
impl Clone for CustomFont
Source§fn clone(&self) -> CustomFont
fn clone(&self) -> CustomFont
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CustomFont
impl RefUnwindSafe for CustomFont
impl Send for CustomFont
impl Sync for CustomFont
impl Unpin for CustomFont
impl UnwindSafe for CustomFont
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more