pub struct Type1Font {Show 19 fields
name: Option<String>,
full_name: Option<String>,
family_name: Option<String>,
weight: Option<String>,
version: Option<String>,
notice: Option<String>,
bbox: BoundingBox<Fixed>,
italic_angle: i32,
is_fixed_pitch: bool,
underline_position: i32,
underline_thickness: i32,
matrix: ScaledFontMatrix,
charstrings: Charstrings,
subrs: Subrs,
encoding: Option<RawEncoding>,
weight_vector: Vec<Fixed>,
multiple_master: Option<MultipleMaster>,
build_char_len: usize,
unicode_charmap: UnicodeCharmap,
}Expand description
A Type1 font.
Fields§
§name: Option<String>§full_name: Option<String>§family_name: Option<String>§weight: Option<String>§version: Option<String>§notice: Option<String>§bbox: BoundingBox<Fixed>§italic_angle: i32§is_fixed_pitch: bool§underline_position: i32§underline_thickness: i32§matrix: ScaledFontMatrix§charstrings: Charstrings§subrs: Subrs§encoding: Option<RawEncoding>§weight_vector: Vec<Fixed>The default blend of a multiple master font, empty for any other.
multiple_master: Option<MultipleMaster>§build_char_len: usizeThe number of elements in the BuildCharArray that othersubrs
read and write.
unicode_charmap: UnicodeCharmapImplementations§
Source§impl Type1Font
impl Type1Font
fn new_impl(data: &[u8]) -> Option<Self>
fn empty() -> Self
fn from_dicts(base: &[u8], private: &[u8]) -> Option<Self>
Sourcepub fn family_name(&self) -> Option<&str>
pub fn family_name(&self) -> Option<&str>
Returns the font family name.
Sourcepub fn italic_angle(&self) -> i32
pub fn italic_angle(&self) -> i32
Returns the italic angle.
Sourcepub fn is_fixed_pitch(&self) -> bool
pub fn is_fixed_pitch(&self) -> bool
Returns true if the glyphs in this font have the same width.
Sourcepub fn underline_position(&self) -> i32
pub fn underline_position(&self) -> i32
Returns the position of the center of an underline decoration.
Sourcepub fn underline_thickness(&self) -> i32
pub fn underline_thickness(&self) -> i32
Returns the suggested size for an underline decoration.
Sourcepub fn bbox(&self) -> BoundingBox<Fixed>
pub fn bbox(&self) -> BoundingBox<Fixed>
Returns the font bounding box.
Sourcepub fn num_glyphs(&self) -> u32
pub fn num_glyphs(&self) -> u32
Returns the number of glyphs in the Type1 font.
Sourcepub fn matrix(&self) -> FontMatrix
pub fn matrix(&self) -> FontMatrix
Returns the top level font matrix.
Sourcepub fn transform(&self, ppem: Option<f32>) -> Transform
pub fn transform(&self, ppem: Option<f32>) -> Transform
Returns the appropriate transform for adjusting points and metrics.
Sourcepub fn unicode_charmap(&self) -> &UnicodeCharmap
pub fn unicode_charmap(&self) -> &UnicodeCharmap
Returns the Unicode charmap for this font.
Note that this is an empty mapping if the agl feature is not enabled.
Sourcepub fn glyph_name(&self, gid: GlyphId) -> Option<&str>
pub fn glyph_name(&self, gid: GlyphId) -> Option<&str>
Returns the glyph name for the given id.
Sourcepub fn glyph_names(&self) -> impl Iterator<Item = (GlyphId, &str)>
pub fn glyph_names(&self) -> impl Iterator<Item = (GlyphId, &str)>
Returns an iterator over the pairs of glyph ids and associated names in the Type1 font.
Sourcepub fn remapped_gid(&self, original_gid: GlyphId) -> GlyphId
pub fn remapped_gid(&self, original_gid: GlyphId) -> GlyphId
Given a glyph identifier in the original glyph order, returns the possibly remapped identifier.
This occurs if we remap or synthesize a .notdef glyph.
Sourcepub fn multiple_master(&self) -> Option<&MultipleMaster>
pub fn multiple_master(&self) -> Option<&MultipleMaster>
Returns the design space of a multiple master font.
None for a font with no masters, or with blend dictionaries that
do not agree.
Sourcepub fn instance<'a>(&'a self, weights: &'a [Fixed]) -> Type1Instance<'a>
pub fn instance<'a>(&'a self, weights: &'a [Fixed]) -> Type1Instance<'a>
Returns the font drawn with the blend that weights give, one per
master.
MultipleMaster::blend_to_weights computes the weights for a
position in the blend space.
Sourcepub fn default_instance(&self) -> Type1Instance<'_>
pub fn default_instance(&self) -> Type1Instance<'_>
Returns the font drawn with its own default blend.
Sourcepub fn evaluate_width(&self, gid: GlyphId) -> Result<Option<Fixed>, Error>
pub fn evaluate_width(&self, gid: GlyphId) -> Result<Option<Fixed>, Error>
Evaluates the charstring for the requested glyph far enough to read its advance width, without drawing it.
A Type 1 charstring states its width in the hsbw or sbw that must
open it, so evaluation stops there.
The font matrix is applied and no size is, so the width is exact and
in the units the rest of the font is measured in.
advance applies a size as well and reports what
draw does.
Unlike evaluate_charstring, the matrix is applied here rather than
left to a caller. That one withholds it so a hinter can be slotted in
ahead of it; nothing hints a width.
Sourcepub fn evaluate_charstring(
&self,
gid: GlyphId,
sink: &mut impl CommandSink,
) -> Result<Option<Fixed>, Error>
pub fn evaluate_charstring( &self, gid: GlyphId, 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 width the charstring states, in the charstring’s own
space: neither the font matrix nor a size is applied, to the width or
to the commands. draw applies both.
Sourcepub fn advance(
&self,
gid: GlyphId,
ppem: Option<f32>,
) -> Result<Option<f32>, Error>
pub fn advance( &self, gid: GlyphId, ppem: Option<f32>, ) -> Result<Option<f32>, Error>
Returns the advance width of the glyph with an optional size in ppem, without drawing it.
This is the width draw reports, arrived at without
the drawing.
Sourcepub fn evaluate_extents(
&self,
gid: GlyphId,
) -> Result<Option<BoundingBox<Fixed>>, Error>
pub fn evaluate_extents( &self, gid: GlyphId, ) -> Result<Option<BoundingBox<Fixed>>, Error>
Measures the box the glyph’s drawing stays within, in design units.
A control box: a curve counts through its control points rather than the path they describe, so one bulging inside its hull measures larger than it draws. HarfBuzz reports a charstring’s extents the same way.
The font matrix is applied and no size is, so the box is exact and in
the units the rest of the font is measured in.
extents applies a size as well and answers in what
a caller laying out text works in.
Unlike evaluate_charstring, the matrix is applied here rather than
left to a caller. That one withholds it so a hinter can be slotted in
before it; nothing hints a box, and a box cannot be brought through a
matrix afterwards anyway, because turning a box turns its corners and
a matrix that shears tilts the drawing inside a box that has to grow
to hold them.
None where the glyph draws nothing.
Sourcepub fn extents(
&self,
gid: GlyphId,
ppem: Option<f32>,
) -> Result<Option<BoundingBox<f32>>, Error>
pub fn extents( &self, gid: GlyphId, ppem: Option<f32>, ) -> Result<Option<BoundingBox<f32>>, Error>
Returns the box the glyph’s drawing stays within, with an optional size in ppem.
The box draw would stay within, measured as
evaluate_extents measures it and scaled by
the size as well.
A size can be applied to a finished box, being one scale in both
directions; it is applied here so the answer matches draw at that
size without a caller doing the arithmetic. The matrix cannot, which
is why neither of these leaves it out.
None where the glyph draws nothing.
Trait Implementations§
Source§impl CharstringContext for Type1Font
impl CharstringContext for Type1Font
Source§fn kind(&self) -> CharstringKind
fn kind(&self) -> CharstringKind
Source§fn seac_components(
&self,
base_code: i32,
accent_code: i32,
) -> Result<[&[u8]; 2], Error>
fn seac_components( &self, base_code: i32, accent_code: i32, ) -> Result<[&[u8]; 2], Error>
seac (standard
encoded accented character) operator.Source§fn subr(&self, index: i32) -> Result<&[u8], Error>
fn subr(&self, index: i32) -> Result<&[u8], Error>
Source§fn global_subr(&self, _index: i32) -> Result<&[u8], Error>
fn global_subr(&self, _index: i32) -> Result<&[u8], Error>
Source§fn weight_vector(&self) -> &[Fixed]
fn weight_vector(&self) -> &[Fixed]
Source§fn build_char_len(&self) -> usize
fn build_char_len(&self) -> usize
BuildCharArray of a multiple
master font, which othersubrs read and write.