Skip to main content

Typeface

Type Alias Typeface 

Source
pub type Typeface = RCHandle<SkTypeface>;

Aliased Type§

pub struct Typeface(/* private fields */);

Implementations§

Source§

impl Typeface

Source

pub fn font_style(&self) -> FontStyle

Returns the typeface’s intrinsic style attributes.

Source

pub fn is_bold(&self) -> bool

Returns true if Self::font_style() weight is at least semi-bold.

Source

pub fn is_italic(&self) -> bool

Returns true if Self::font_style() is not upright.

Source

pub fn is_fixed_pitch(&self) -> bool

Returns true if the typeface claims to be fixed-pitch.

This is a style bit; advance widths may vary even when this returns true.

Source

pub fn variation_design_position(&self) -> Option<Vec<Coordinate>>

Returns the design variation coordinates for this typeface.

Returns the number of axes and copies the coordinates if available. Returns None on error.

Source

pub fn variation_design_parameters(&self) -> Option<Vec<VariationAxis>>

Returns the design variation parameters for this typeface.

Returns the number of axes and copies the parameters if available. Returns None on error.

Source

pub fn is_synthetic_bold(&self) -> bool

Returns true if the typeface is internally being fake-bolded.

Source

pub fn is_synthetic_oblique(&self) -> bool

Returns true if the typeface is internally being fake-obliqued.

Source

pub fn unique_id(&self) -> TypefaceId

Source

pub fn equal(face_a: impl AsRef<Typeface>, face_b: impl AsRef<Typeface>) -> bool

Returns true if the two typefaces reference the same underlying font.

None does not compare equal to any typeface.

  • face_a: first typeface.
  • face_b: second typeface.
Source

pub fn clone_with_arguments( &self, arguments: &FontArguments<'_, '_>, ) -> Option<Typeface>

Returns a typeface based on this typeface and parameterized by arguments.

If arguments does not supply a value for some font parameter, the value from this typeface is used.

  • arguments: clone parameters to apply.
Source

pub fn serialize_stream(&self, write: impl Write, behavior: SerializeBehavior)

Writes a signature sufficient to reconstruct a typeface referencing the same font.

  • write: destination stream.
  • behavior: controls whether font data is included.
Source

pub fn serialize(&self, behavior: SerializeBehavior) -> Data

Returns serialized typeface data.

  • behavior: controls whether font data is included.
Source

pub fn make_deserialize( data: impl Read, last_resort_mgr: impl Into<Option<FontMgr>>, ) -> Option<Typeface>

Deserializes a typeface previously produced by Self::serialize() or Self::serialize_stream().

Goes through all registered typeface factories and last_resort_mgr when provided.

  • data: serialized typeface bytes.
  • last_resort_mgr: optional fallback font manager.
Source

pub fn unichars_to_glyphs(&self, uni: &[Unichar], glyphs: &mut [GlyphId])

Converts UTF-32 code points to glyph IDs.

  • uni: UTF-32 code points.
  • glyphs: output glyph IDs.
Source

pub fn str_to_glyphs( &self, str: impl AsRef<str>, glyphs: &mut [GlyphId], ) -> usize

Converts UTF-8 text to glyph IDs.

  • str: input text.
  • glyphs: output glyph IDs.
Source

pub fn text_to_glyphs( &self, text: impl EncodedText, glyphs: &mut [GlyphId], ) -> usize

Converts encoded text to glyph IDs.

  • text: encoded text input.
  • glyphs: output glyph IDs.
Source

pub fn unichar_to_glyph(&self, unichar: Unichar) -> GlyphId

Returns the glyph ID corresponding to a Unicode code point.

Returns 0 when the code point is not supported.

  • unichar: Unicode code point.
Source

pub fn count_glyphs(&self) -> usize

Returns the number of glyphs in the typeface.

Source

pub fn count_tables(&self) -> usize

Returns the number of tables in the font.

Source

pub fn table_tags(&self) -> Option<Vec<FontTableTag>>

👎Deprecated since 0.88.0: use read_table_tags
Source

pub fn read_table_tags(&self) -> Option<Vec<FontTableTag>>

Returns the list of table tags in the font.

Returns None on error.

Source

pub fn get_table_size(&self, tag: FontTableTag) -> Option<usize>

Returns the size, in bytes, of table tag.

Returns None if the table is not present.

  • tag: table tag.
Source

pub fn get_table_data(&self, tag: FontTableTag, data: &mut [u8]) -> usize

Copies table tag data into data.

Returns the number of bytes copied.

  • tag: table tag.
  • data: destination buffer.
Source

pub fn copy_table_data(&self, tag: FontTableTag) -> Option<Data>

Returns an immutable copy of table tag data.

Returns None if the table is not found.

  • tag: table tag.
Source

pub fn units_per_em(&self) -> Option<i32>

Returns the units-per-em value for this typeface.

Returns None on error.

Source

pub fn get_kerning_pair_adjustments( &self, glyphs: &[GlyphId], adjustments: &mut [i32], ) -> bool

Returns horizontal kerning adjustments for glyphs.

Adjustments are in design units relative to units-per-em.

  • glyphs: input glyph run.
  • adjustments: output adjustments; length should be glyphs.len() - 1.
Source

pub fn new_family_name_iterator(&self) -> impl Iterator<Item = LocalizedString>

Returns an iterator over all family names specified by the font.

Source

pub fn family_name(&self) -> String

Returns the family name for this typeface as UTF-8.

Source

pub fn post_script_name(&self) -> Option<String>

Returns the PostScript name for this typeface.

The value may vary with variation parameters.

Source

pub fn resource_name(&self) -> Option<String>

Returns a user-facing name for the primary resource backing this typeface.

Returns None when no resource name is available.

Source

pub fn to_font_data(&self) -> Option<(Vec<u8>, usize)>

Returns raw font data bytes and the TTC index.

Returns None on failure.

Source

pub fn bounds(&self) -> Rect

Returns the union of glyph bounds, scaled to 1pt.

Trait Implementations§

Source§

impl Debug for Typeface

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for Typeface

Source§

impl Sync for Typeface