Skip to main content

Type1Font

Struct Type1Font 

Source
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: usize

The number of elements in the BuildCharArray that othersubrs read and write.

§unicode_charmap: UnicodeCharmap

Implementations§

Source§

impl Type1Font

Source

pub fn new(data: &[u8]) -> Result<Self, Error>

Creates a new Type1 font from the given data.

Source

fn new_impl(data: &[u8]) -> Option<Self>

Source

fn empty() -> Self

Source

fn from_dicts(base: &[u8], private: &[u8]) -> Option<Self>

Source

pub fn name(&self) -> Option<&str>

Returns the PostScript name.

Source

pub fn full_name(&self) -> Option<&str>

Returns the full font name.

Source

pub fn family_name(&self) -> Option<&str>

Returns the font family name.

Source

pub fn weight(&self) -> Option<&str>

Returns the weight or style name.

Source

pub fn version(&self) -> Option<&str>

Returns the font version string.

Source

pub fn notice(&self) -> Option<&str>

Returns the font’s copyright or trademark notice.

Source

pub fn italic_angle(&self) -> i32

Returns the italic angle.

Source

pub fn is_fixed_pitch(&self) -> bool

Returns true if the glyphs in this font have the same width.

Source

pub fn underline_position(&self) -> i32

Returns the position of the center of an underline decoration.

Source

pub fn underline_thickness(&self) -> i32

Returns the suggested size for an underline decoration.

Source

pub fn bbox(&self) -> BoundingBox<Fixed>

Returns the font bounding box.

Source

pub fn num_glyphs(&self) -> u32

Returns the number of glyphs in the Type1 font.

Source

pub fn upem(&self) -> i32

Returns the units per em.

Source

pub fn matrix(&self) -> FontMatrix

Returns the top level font matrix.

Source

pub fn transform(&self, ppem: Option<f32>) -> Transform

Returns the appropriate transform for adjusting points and metrics.

Source

pub fn encoding(&self) -> Option<Encoding<'_>>

Returns the character encoding.

Source

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.

Source

pub fn glyph_name(&self, gid: GlyphId) -> Option<&str>

Returns the glyph name for the given id.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn default_instance(&self) -> Type1Instance<'_>

Returns the font drawn with its own default blend.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn draw( &self, gid: GlyphId, ppem: Option<f32>, sink: &mut impl PathSink, ) -> 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.

Trait Implementations§

Source§

impl CharstringContext for Type1Font

Source§

fn kind(&self) -> CharstringKind

Returns the type of the charstring.
Source§

fn seac_components( &self, base_code: i32, accent_code: i32, ) -> Result<[&[u8]; 2], Error>

Returns the base and accent charstrings for the seac (standard encoded accented character) operator.
Source§

fn subr(&self, index: i32) -> Result<&[u8], Error>

Returns the charstring for the local subroutine at the given index as encoded in the calling charstring.
Source§

fn global_subr(&self, _index: i32) -> Result<&[u8], Error>

Returns the charstring for the global subroutine at the given index as encoded in the calling charstring.
Source§

fn weight_vector(&self) -> &[Fixed]

Returns the current active weight vector for a multiple master font.
Source§

fn build_char_len(&self) -> usize

Returns the number of elements in the BuildCharArray of a multiple master font, which othersubrs read and write.

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> ErasedDestructor for T
where T: 'static,

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.