pub type Typeface = RCHandle<SkTypeface>;Aliased Type§
pub struct Typeface(/* private fields */);Implementations§
Source§impl Typeface
impl Typeface
Sourcepub fn font_style(&self) -> FontStyle
pub fn font_style(&self) -> FontStyle
Returns the typeface’s intrinsic style attributes.
Sourcepub fn is_bold(&self) -> bool
pub fn is_bold(&self) -> bool
Returns true if Self::font_style() weight is at least semi-bold.
Sourcepub fn is_italic(&self) -> bool
pub fn is_italic(&self) -> bool
Returns true if Self::font_style() is not upright.
Sourcepub fn is_fixed_pitch(&self) -> bool
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.
Sourcepub fn variation_design_position(&self) -> Option<Vec<Coordinate>>
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.
Sourcepub fn variation_design_parameters(&self) -> Option<Vec<VariationAxis>>
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.
Sourcepub fn is_synthetic_bold(&self) -> bool
pub fn is_synthetic_bold(&self) -> bool
Returns true if the typeface is internally being fake-bolded.
Sourcepub fn is_synthetic_oblique(&self) -> bool
pub fn is_synthetic_oblique(&self) -> bool
Returns true if the typeface is internally being fake-obliqued.
pub fn unique_id(&self) -> TypefaceId
Sourcepub fn equal(face_a: impl AsRef<Typeface>, face_b: impl AsRef<Typeface>) -> bool
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.
Sourcepub fn clone_with_arguments(
&self,
arguments: &FontArguments<'_, '_>,
) -> Option<Typeface>
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.
Sourcepub fn serialize_stream(&self, write: impl Write, behavior: SerializeBehavior)
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.
Sourcepub fn serialize(&self, behavior: SerializeBehavior) -> Data
pub fn serialize(&self, behavior: SerializeBehavior) -> Data
Returns serialized typeface data.
behavior: controls whether font data is included.
Sourcepub fn make_deserialize(
data: impl Read,
last_resort_mgr: impl Into<Option<FontMgr>>,
) -> Option<Typeface>
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.
Sourcepub fn unichars_to_glyphs(&self, uni: &[Unichar], glyphs: &mut [GlyphId])
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.
Sourcepub fn str_to_glyphs(
&self,
str: impl AsRef<str>,
glyphs: &mut [GlyphId],
) -> usize
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.
Sourcepub fn text_to_glyphs(
&self,
text: impl EncodedText,
glyphs: &mut [GlyphId],
) -> usize
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.
Sourcepub fn unichar_to_glyph(&self, unichar: Unichar) -> GlyphId
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.
Sourcepub fn count_glyphs(&self) -> usize
pub fn count_glyphs(&self) -> usize
Returns the number of glyphs in the typeface.
Sourcepub fn count_tables(&self) -> usize
pub fn count_tables(&self) -> usize
Returns the number of tables in the font.
Returns the list of table tags in the font.
Returns None on error.
Sourcepub fn get_table_size(&self, tag: FontTableTag) -> Option<usize>
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.
Sourcepub fn get_table_data(&self, tag: FontTableTag, data: &mut [u8]) -> usize
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.
Sourcepub fn copy_table_data(&self, tag: FontTableTag) -> Option<Data>
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.
Sourcepub fn units_per_em(&self) -> Option<i32>
pub fn units_per_em(&self) -> Option<i32>
Returns the units-per-em value for this typeface.
Returns None on error.
Sourcepub fn get_kerning_pair_adjustments(
&self,
glyphs: &[GlyphId],
adjustments: &mut [i32],
) -> bool
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 beglyphs.len() - 1.
Sourcepub fn new_family_name_iterator(&self) -> impl Iterator<Item = LocalizedString>
pub fn new_family_name_iterator(&self) -> impl Iterator<Item = LocalizedString>
Returns an iterator over all family names specified by the font.
Sourcepub fn family_name(&self) -> String
pub fn family_name(&self) -> String
Returns the family name for this typeface as UTF-8.
Sourcepub fn post_script_name(&self) -> Option<String>
pub fn post_script_name(&self) -> Option<String>
Returns the PostScript name for this typeface.
The value may vary with variation parameters.
Sourcepub fn resource_name(&self) -> Option<String>
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.