pub struct CFF<'a> {
pub header: Header,
pub name_index: Index<'a>,
pub string_index: MaybeOwnedIndex<'a>,
pub global_subr_index: Index<'a>,
pub fonts: Vec<Font<'a>>,
}
Expand description
Top level representation of a CFF font file, typically read from a CFF OpenType table.
Refer to Technical Note #5176
Fields
header: Header
name_index: Index<'a>
string_index: MaybeOwnedIndex<'a>
global_subr_index: Index<'a>
fonts: Vec<Font<'a>>
Implementations
sourceimpl<'a> CFF<'a>
impl<'a> CFF<'a>
sourcepub fn subset(
&'a self,
glyph_ids: &[u16],
convert_cff_to_cid_if_more_than_255_glyphs: bool
) -> Result<SubsetCFF<'a>, ParseError>
pub fn subset(
&'a self,
glyph_ids: &[u16],
convert_cff_to_cid_if_more_than_255_glyphs: bool
) -> Result<SubsetCFF<'a>, ParseError>
glpyh_ids
contains the ids of the glyphs to retain.
When subsetting a Type 1 CFF font and retaining more than 255 glyphs the
convert_cff_to_cid_if_more_than_255_glyphs
argument controls whether the Type 1 font
is converted to a CID keyed font in the process. The primary motivation for this is
broader compatibility, especially if the subset font is embedded in a PDF.
Known Limitations
Currently the subsetting process does not produce the smallest possible output font. There are various parts of the source font that are copied to the output font as-is. Specifically the subsetting process does not subset the String INDEX, or the Local or Global subroutines.
Subsetting the String INDEX requires updating all String IDs (SID) in the font so that they point at their new position in the String INDEX. Subsetting the subroutines requires parsing the CharStrings, which describe the glyph outlines. The CharStrings format is non-trivial so this has been left for now.
sourceimpl<'a> CFF<'a>
impl<'a> CFF<'a>
sourcepub fn read_string(&self, sid: u16) -> Result<String, ParseError>
pub fn read_string(&self, sid: u16) -> Result<String, ParseError>
Read a string with the given SID from the String INDEX
Trait Implementations
sourceimpl<'a> OutlineBuilder for CFF<'a>
impl<'a> OutlineBuilder for CFF<'a>
sourceimpl<'a> ReadBinary<'a> for CFF<'a>
impl<'a> ReadBinary<'a> for CFF<'a>
sourceimpl<'a> WriteBinary<&CFF<'a>> for CFF<'a>
impl<'a> WriteBinary<&CFF<'a>> for CFF<'a>
sourcefn write<C: WriteContext>(ctxt: &mut C, cff: &CFF<'a>) -> Result<(), WriteError>
fn write<C: WriteContext>(ctxt: &mut C, cff: &CFF<'a>) -> Result<(), WriteError>
Write the binary representation of Self to ctxt
.
Auto Trait Implementations
impl<'a> RefUnwindSafe for CFF<'a>
impl<'a> Send for CFF<'a>
impl<'a> Sync for CFF<'a>
impl<'a> Unpin for CFF<'a>
impl<'a> UnwindSafe for CFF<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, T> ReadBinaryDep<'a> for T where
T: ReadBinary<'a>,
impl<'a, T> ReadBinaryDep<'a> for T where
T: ReadBinary<'a>,
type Args = ()
type HostType = <T as ReadBinary<'a>>::HostType
fn read_dep(
ctxt: &mut ReadCtxt<'a>,
<T as ReadBinaryDep<'a>>::Args
) -> Result<<T as ReadBinaryDep<'a>>::HostType, ParseError>
sourceimpl<T, HostType> WriteBinaryDep<HostType> for T where
T: WriteBinary<HostType>,
impl<T, HostType> WriteBinaryDep<HostType> for T where
T: WriteBinary<HostType>,
type Output = <T as WriteBinary<HostType>>::Output
type Output = <T as WriteBinary<HostType>>::Output
The type of the value returned by write_dep
.
sourcefn write_dep<C>(
ctxt: &mut C,
val: HostType,
<T as WriteBinaryDep<HostType>>::Args
) -> Result<<T as WriteBinaryDep<HostType>>::Output, WriteError> where
C: WriteContext,
fn write_dep<C>(
ctxt: &mut C,
val: HostType,
<T as WriteBinaryDep<HostType>>::Args
) -> Result<<T as WriteBinaryDep<HostType>>::Output, WriteError> where
C: WriteContext,
Write the binary representation of Self to ctxt
.