Pattern

Struct Pattern 

Source
pub struct Pattern(/* private fields */);
Expand description

Representation of a borrowed fontconfig’s sys::FcPattern.

An Pattern is an opaque type that holds both patterns to match against the available fonts, as well as the information about each font.

Implementations§

Source§

impl Pattern

Source

pub fn del(&mut self, name: &CStr) -> bool

Delete a property from a pattern

Source

pub fn print(&self)

Print this pattern to stdout with all its values.

Source

pub fn filter(&self, os: Option<&mut ObjectSet>) -> Option<OwnedPattern>

Filter the objects of pattern

Returns a new pattern that only has those objects from self that are in os. If os is None, a duplicate of self is returned.

Source

pub fn format(&self, fmt: &CStr) -> Option<FcStr>

Format a pattern into a string according to a format specifier

See: pattern-format

Source

pub fn default_substitute(&mut self)

Perform default substitutions in a pattern

Supplies default values for underspecified font patterns:

  • Patterns without a specified style or weight are set to Medium
  • Patterns without a specified style or slant are set to Roman
  • Patterns without a specified pixel size are given one computed from any specified point size (default 12), dpi (default 75) and scale (default 1).
Source

pub fn font_match(&mut self, config: &mut FontConfig) -> OwnedPattern

Get the best available match for this pattern, returned as a new pattern.

Finds the font in sets most closely matching pattern and returns the result of Pattern::render_prepare for that font and the provided pattern.
This function should be called only after FontConfig::substitute and Pattern::default_substitute have been called for the pattern.
otherwise the results will not be correct.

Source

pub fn font_list( &self, config: &mut FontConfig, os: Option<&mut ObjectSet>, ) -> FontSet<'_>

List fonts

Selects fonts matching self, creates patterns from those fonts containing only the objects in os and returns the set of unique such patterns.

Source

pub fn font_sort( &mut self, config: &mut FontConfig, trim: bool, ) -> Result<FontSet<'static>, Error>

Get the list of fonts sorted by closeness to self.

If trim is true, elements in the list which don’t include Unicode coverage not provided by earlier elements in the list are elided.
This function should be called only after FontConfig::substitute and Pattern::default_substitute have been called for this pattern;
otherwise the results will not be correct.

Source

pub fn font_sort_with_charset( &mut self, config: &mut FontConfig, trim: bool, ) -> Option<(FontSet<'_>, OwnedCharSet)>

Get the list of fonts sorted by closeness to self.

If trim is true, elements in the list which don’t include Unicode coverage not provided by earlier elements in the list are elided.
The union of Unicode coverage of all of the fonts is returned in CharSet.
This function should be called only after FontConfig::substitute and Pattern::default_substitute have been called for this pattern;
otherwise the results will not be correct.

Source

pub fn render_prepare( &mut self, config: &mut FontConfig, font: &mut Self, ) -> OwnedPattern

Prepare pattern for loading font file.

Creates a new pattern consisting of elements of font not appearing in pat, elements of pat not appearing in font and the best matching value from pat for elements appearing in both.
The result is passed to [FontConfig::substitute_with_pat] with kind crate::MatchKind::Font and then returned.

Source

pub fn charset(&self) -> Option<&CharSet>

Get character map

Source

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

Get the “fullname” (human-readable name) of this pattern.

Source

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

Get the “file” (path on the filesystem) of this font pattern.

Source

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

Get the “index” (The index of the font within the file) of this pattern.

Source

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

Get the “slant” (Italic, oblique or roman) of this pattern.

Source

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

Get the “weight” (Light, medium, demibold, bold or black) of this pattern.

Source

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

Get the “width” (Condensed, normal or expanded) of this pattern.

Source

pub fn fontformat(&self) -> Result<FontFormat, Error>

Get the “fontformat” (“TrueType” “Type 1” “BDF” “PCF” “Type 42” “CID Type 1” “CFF” “PFR” “Windows FNT”) of this pattern.

Source

pub fn hash(&self) -> u32

Source§

impl Pattern

Source

pub fn lang_set(&self) -> Option<LangSet>

Get the languages set of this pattern.

Source

pub fn matrix(&mut self) -> Option<&Matrix>

Get the matrix from this pattern.

Source

pub fn get<'a, 'pat, V>( &'pat self, name: &'a Property<'pat, V>, index: usize, ) -> Option<V::Returns>
where V: PropertyType<'pat>,

Source

pub fn add<'a, 'pat, V>( &'pat mut self, name: &'a Property<'pat, V>, value: V, ) -> bool
where V: PropertyType<'pat>,

Trait Implementations§

Source§

impl AsMut<Pattern> for OwnedPattern

Source§

fn as_mut(&mut self) -> &mut Pattern

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Pattern> for OwnedPattern

Source§

fn as_ref(&self) -> &Pattern

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<Pattern> for OwnedPattern

Source§

fn borrow(&self) -> &Pattern

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<Pattern> for OwnedPattern

Source§

fn borrow_mut(&mut self) -> &mut Pattern

Mutably borrows from an owned value. Read more
Source§

impl Debug for Pattern

Source§

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

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

impl ToOwned for Pattern

Source§

type Owned = OwnedPattern

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> OwnedPattern

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

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> 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.