pub struct CffFontRef<'a> {
data: &'a [u8],
is_cff2: bool,
upem: i32,
global_subrs: Index<'a>,
top_dict: TopDict<'a>,
top_dict_index: u16,
}Expand description
A CFF or CFF2 font.
The source data may be a raw CFF blob as embedded in a PDF or the content of a CFF or CFF2 table in an OpenType font.
Fields§
§data: &'a [u8]§is_cff2: bool§upem: i32§global_subrs: Index<'a>§top_dict: TopDict<'a>§top_dict_index: u16Implementations§
Source§impl<'a> CffFontRef<'a>
impl<'a> CffFontRef<'a>
Sourcepub fn new(
data: &'a [u8],
top_dict_index: u32,
upem: Option<i32>,
) -> Result<Self, Error>
pub fn new( data: &'a [u8], top_dict_index: u32, upem: Option<i32>, ) -> Result<Self, Error>
Creates a new font for the given CFF or CFF2 data.
Tries to determine the CFF version by reading the first word of the header.
For CFF blobs embedded in an OpenType font, the upem should be taken
from the head table. Otherwise, 1000 will be assumed.
Sourcepub fn new_cff(
data: &'a [u8],
top_dict_index: u32,
upem: Option<i32>,
) -> Result<Self, Error>
pub fn new_cff( data: &'a [u8], top_dict_index: u32, upem: Option<i32>, ) -> Result<Self, Error>
Creates a new font for the given CFF data.
For CFF blobs embedded in an OpenType font, the upem should be taken
from the head table. Otherwise, 1000 will be assumed.
Sourcepub fn new_cff2(data: &'a [u8], upem: Option<i32>) -> Result<Self, Error>
pub fn new_cff2(data: &'a [u8], upem: Option<i32>) -> Result<Self, Error>
Creates a new font for the given CFF2 data.
For CFF blobs embedded in an OpenType font, the upem should be taken
from the head table. Otherwise, 1000 will be assumed.
fn new_impl( data: &'a [u8], is_cff2: bool, upem: Option<i32>, top_dict_data: &'a [u8], top_dict_index: u16, strings: Index<'a>, global_subrs: Index<'a>, ) -> Result<Self, Error>
Sourcepub fn metadata(&self) -> Option<Metadata<'a>>
pub fn metadata(&self) -> Option<Metadata<'a>>
Returns additional metadata such as font names and metrics.
Sourcepub fn global_subrs(&self) -> &Index<'a>
pub fn global_subrs(&self) -> &Index<'a>
Returns the global subroutine index.
Sourcepub fn num_glyphs(&self) -> u32
pub fn num_glyphs(&self) -> u32
Returns the number of glyphs in the CFF font.
Sourcepub fn charstrings(&self) -> &Index<'a>
pub fn charstrings(&self) -> &Index<'a>
Returns the charstring index.
Sourcepub fn string(&self, sid: Sid) -> Option<&'a [u8]>
pub fn string(&self, sid: Sid) -> Option<&'a [u8]>
Returns the string for the given identifier.
Sourcepub fn charset(&self) -> Option<Charset<'a>>
pub fn charset(&self) -> Option<Charset<'a>>
Returns the mapping for glyph identifiers.
For a CID font, this maps between CIDs and glyph identifiers. Otherwise maps between SIDs and glyph identifiers.
Sourcepub fn encoding(&self) -> Option<Encoding<'a>>
pub fn encoding(&self) -> Option<Encoding<'a>>
Returns the mapping from character codes to glyph identifiers.
Sourcepub fn matrix(&self) -> Option<&ScaledFontMatrix>
pub fn matrix(&self) -> Option<&ScaledFontMatrix>
Returns the top level font matrix.
Sourcepub fn var_store(&self) -> Option<&ItemVariationStore<'a>>
pub fn var_store(&self) -> Option<&ItemVariationStore<'a>>
Returns the item variation store.
Only present for CFF2 variable fonts.
Sourcepub fn num_subfonts(&self) -> u16
pub fn num_subfonts(&self) -> u16
Returns the number of available subfonts.
Sourcepub fn subfont_index(&self, gid: GlyphId) -> Option<u16>
pub fn subfont_index(&self, gid: GlyphId) -> Option<u16>
Returns the subfont index for the given glyph.
Sourcepub fn subfont(&self, index: u16, coords: &[F2Dot14]) -> Result<Subfont, Error>
pub fn subfont(&self, index: u16, coords: &[F2Dot14]) -> Result<Subfont, Error>
Returns the subfont with the given index and normalized variation coordinates.
Sourcepub fn subfont_hinted(
&self,
index: u16,
coords: &[F2Dot14],
) -> Result<(Subfont, HintingParams), Error>
pub fn subfont_hinted( &self, index: u16, coords: &[F2Dot14], ) -> Result<(Subfont, HintingParams), Error>
Returns the subfont and hinting parameters for the given index and normalized variation coordinates.
Sourcepub fn transform(&self, subfont: &Subfont, ppem: Option<f32>) -> Transform
pub fn transform(&self, subfont: &Subfont, ppem: Option<f32>) -> Transform
Returns the effective transform for the given subfont and optional size in pixels per em.
Sourcepub fn evaluate_charstring(
&self,
subfont: &Subfont,
gid: GlyphId,
coords: &[F2Dot14],
sink: &mut impl CommandSink,
) -> Result<Option<Fixed>, Error>
pub fn evaluate_charstring( &self, subfont: &Subfont, gid: GlyphId, coords: &[F2Dot14], sink: &mut impl CommandSink, ) -> Result<Option<Fixed>, Error>
Evaluates the charstring for the requested glyph and sends the results to the given sink.
Returns the advance with of the glyph in font units if the charstring provides one.
Sourcepub fn draw(
&self,
subfont: &Subfont,
gid: GlyphId,
coords: &[F2Dot14],
ppem: Option<f32>,
pen: &mut impl OutlinePen,
) -> Result<Option<f32>, Error>
pub fn draw( &self, subfont: &Subfont, gid: GlyphId, coords: &[F2Dot14], ppem: Option<f32>, pen: &mut impl OutlinePen, ) -> Result<Option<f32>, Error>
Draws the glyph with an optional size in ppem to the given pen.
Returns the advance width of the glyph if the charstring provides one.
Sourcefn blend_state(
&self,
vs_index: u16,
coords: &'a [F2Dot14],
) -> Option<BlendState<'a>>
fn blend_state( &self, vs_index: u16, coords: &'a [F2Dot14], ) -> Option<BlendState<'a>>
Returns a blend state for the given variation store index and normalized coordinates.
Trait Implementations§
Source§impl<'a> Clone for CffFontRef<'a>
impl<'a> Clone for CffFontRef<'a>
Source§fn clone(&self) -> CffFontRef<'a>
fn clone(&self) -> CffFontRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more