[]Struct pango::FontDescription

pub struct FontDescription(_);

The FontDescription structure represents the description of an ideal font. These structures are used both to list what fonts are available on the system and also for specifying the characteristics of a font to load.

Implementations

impl FontDescription[src]

pub fn new() -> FontDescription[src]

Creates a new font description structure with all fields unset.

Returns

the newly allocated FontDescription, which should be freed using FontDescription::free.

pub fn better_match(
    &self,
    old_match: Option<&FontDescription>,
    new_match: &FontDescription
) -> bool
[src]

Determines if the style attributes of new_match are a closer match for self than those of old_match are, or if old_match is None, determines if new_match is a match at all. Approximate matching is done for weight and style; other style attributes must match exactly. Style attributes are all attributes other than family and size-related attributes. Approximate matching for style considers PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC as matches, but not as good a match as when the styles are equal.

Note that old_match must match self.

old_match

a FontDescription, or None

new_match

a FontDescription

Returns

true if new_match is a better match

pub fn get_family(&self) -> Option<GString>[src]

Gets the family name field of a font description. See FontDescription::set_family.

Returns

the family name field for the font description, or None if not previously set. This has the same life-time as the font description itself and should not be freed.

pub fn get_gravity(&self) -> Gravity[src]

Gets the gravity field of a font description. See FontDescription::set_gravity.

Returns

the gravity field for the font description. Use FontDescription::get_set_fields to find out if the field was explicitly set or not.

pub fn get_set_fields(&self) -> FontMask[src]

Determines which fields in a font description have been set.

Returns

a bitmask with bits set corresponding to the fields in self that have been set.

pub fn get_size(&self) -> i32[src]

Gets the size field of a font description. See FontDescription::set_size.

Returns

the size field for the font description in points or device units. You must call FontDescription::get_size_is_absolute to find out which is the case. Returns 0 if the size field has not previously been set or it has been set to 0 explicitly. Use FontDescription::get_set_fields to find out if the field was explicitly set or not.

pub fn get_size_is_absolute(&self) -> bool[src]

Determines whether the size of the font is in points (not absolute) or device units (absolute). See FontDescription::set_size and FontDescription::set_absolute_size.

Returns

whether the size for the font description is in points or device units. Use FontDescription::get_set_fields to find out if the size field of the font description was explicitly set or not.

pub fn get_stretch(&self) -> Stretch[src]

Gets the stretch field of a font description. See FontDescription::set_stretch.

Returns

the stretch field for the font description. Use FontDescription::get_set_fields to find out if the field was explicitly set or not.

pub fn get_style(&self) -> Style[src]

Gets the style field of a FontDescription. See FontDescription::set_style.

Returns

the style field for the font description. Use FontDescription::get_set_fields to find out if the field was explicitly set or not.

pub fn get_variant(&self) -> Variant[src]

Gets the variant field of a FontDescription. See FontDescription::set_variant.

Returns

the variant field for the font description. Use FontDescription::get_set_fields to find out if the field was explicitly set or not.

pub fn get_variations(&self) -> Option<GString>[src]

Gets the variations field of a font description. See FontDescription::set_variations.

Feature: v1_42

Returns

the varitions field for the font description, or None if not previously set. This has the same life-time as the font description itself and should not be freed.

pub fn get_weight(&self) -> Weight[src]

Gets the weight field of a font description. See FontDescription::set_weight.

Returns

the weight field for the font description. Use FontDescription::get_set_fields to find out if the field was explicitly set or not.

pub fn merge(
    &mut self,
    desc_to_merge: Option<&FontDescription>,
    replace_existing: bool
)
[src]

Merges the fields that are set in desc_to_merge into the fields in self. If replace_existing is false, only fields in self that are not already set are affected. If true, then fields that are already set will be replaced as well.

If desc_to_merge is None, this function performs nothing.

desc_to_merge

the FontDescription to merge from, or None

replace_existing

if true, replace fields in self with the corresponding values from desc_to_merge, even if they are already exist.

pub fn set_absolute_size(&mut self, size: f64)[src]

Sets the size field of a font description, in device units. This is mutually exclusive with FontDescription::set_size which sets the font size in points.

size

the new size, in Pango units. There are PANGO_SCALE Pango units in one device unit. For an output backend where a device unit is a pixel, a size value of 10 * PANGO_SCALE gives a 10 pixel font.

pub fn set_family(&mut self, family: &str)[src]

Sets the family name field of a font description. The family name represents a family of related font styles, and will resolve to a particular FontFamily. In some uses of FontDescription, it is also possible to use a comma separated list of family names for this field.

family

a string representing the family name.

pub fn set_gravity(&mut self, gravity: Gravity)[src]

Sets the gravity field of a font description. The gravity field specifies how the glyphs should be rotated. If gravity is Gravity::Auto, this actually unsets the gravity mask on the font description.

This function is seldom useful to the user. Gravity should normally be set on a Context.

gravity

the gravity for the font description.

pub fn set_size(&mut self, size: i32)[src]

Sets the size field of a font description in fractional points. This is mutually exclusive with FontDescription::set_absolute_size.

size

the size of the font in points, scaled by PANGO_SCALE. (That is, a size value of 10 * PANGO_SCALE is a 10 point font. The conversion factor between points and device units depends on system configuration and the output device. For screen display, a logical DPI of 96 is common, in which case a 10 point font corresponds to a 10 * (96 / 72) = 13.3 pixel font. Use FontDescription::set_absolute_size if you need a particular size in device units.

pub fn set_stretch(&mut self, stretch: Stretch)[src]

Sets the stretch field of a font description. The stretch field specifies how narrow or wide the font should be.

stretch

the stretch for the font description

pub fn set_style(&mut self, style: Style)[src]

Sets the style field of a FontDescription. The Style enumeration describes whether the font is slanted and the manner in which it is slanted; it can be either Style::Normal, Style::Italic, or Style::Oblique. Most fonts will either have a italic style or an oblique style, but not both, and font matching in Pango will match italic specifications with oblique fonts and vice-versa if an exact match is not found.

style

the style for the font description

pub fn set_variant(&mut self, variant: Variant)[src]

Sets the variant field of a font description. The Variant can either be Variant::Normal or Variant::SmallCaps.

variant

the variant type for the font description.

pub fn set_variations(&mut self, variations: &str)[src]

Sets the variations field of a font description. OpenType font variations allow to select a font instance by specifying values for a number of axes, such as width or weight.

The format of the variations string is AXIS1=VALUE,AXIS2=VALUE..., with each AXIS a 4 character tag that identifies a font axis, and each VALUE a floating point number. Unknown axes are ignored, and values are clamped to their allowed range.

Pango does not currently have a way to find supported axes of a font. Both harfbuzz or freetype have API for this.

Feature: v1_42

variations

a string representing the variations

pub fn set_variations_static(&mut self, variations: &str)[src]

Like FontDescription::set_variations, except that no copy of variations is made. The caller must make sure that the string passed in stays around until self has been freed or the name is set again. This function can be used if variations is a static string such as a C string literal, or if self is only needed temporarily.

Feature: v1_42

variations

a string representing the variations

pub fn set_weight(&mut self, weight: Weight)[src]

Sets the weight field of a font description. The weight field specifies how bold or light the font should be. In addition to the values of the Weight enumeration, other intermediate numeric values are possible.

weight

the weight for the font description.

pub fn to_filename(&self) -> Option<GString>[src]

Creates a filename representation of a font description. The filename is identical to the result from calling FontDescription::to_string, but with underscores instead of characters that are untypical in filenames, and in lower case only.

Returns

a new string that must be freed with g_free.

pub fn unset_fields(&mut self, to_unset: FontMask)[src]

Unsets some of the fields in a FontDescription. The unset fields will get back to their default values.

to_unset

bitmask of fields in the self to unset.

pub fn from_string(str: &str) -> FontDescription[src]

Creates a new font description from a string representation in the form

"[FAMILY-LIST] [STYLE-OPTIONS] [SIZE] [VARIATIONS]",

where FAMILY-LIST is a comma-separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace-separated list of words where each word describes one of style, variant, weight, stretch, or gravity, and SIZE is a decimal number (size in points) or optionally followed by the unit modifier "px" for absolute size. VARIATIONS is a comma-separated list of font variation specifications of the form "@axis=value" (the = sign is optional).

The following words are understood as styles: "Normal", "Roman", "Oblique", "Italic".

The following words are understood as variants: "Small-Caps".

The following words are understood as weights: "Thin", "Ultra-Light", "Extra-Light", "Light", "Semi-Light", "Demi-Light", "Book", "Regular", "Medium", "Semi-Bold", "Demi-Bold", "Bold", "Ultra-Bold", "Extra-Bold", "Heavy", "Black", "Ultra-Black", "Extra-Black".

The following words are understood as stretch values: "Ultra-Condensed", "Extra-Condensed", "Condensed", "Semi-Condensed", "Semi-Expanded", "Expanded", "Extra-Expanded", "Ultra-Expanded".

The following words are understood as gravity values: "Not-Rotated", "South", "Upside-Down", "North", "Rotated-Left", "East", "Rotated-Right", "West".

Any one of the options may be absent. If FAMILY-LIST is absent, then the family_name field of the resulting font description will be initialized to None. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0.

A typical example:

"Cantarell Italic Light 15 @wght=200"

str

string representation of a font description.

Returns

a new FontDescription.

Trait Implementations

impl Clone for FontDescription

impl Debug for FontDescription[src]

impl Default for FontDescription[src]

impl Display for FontDescription[src]

impl Eq for FontDescription[src]

impl Hash for FontDescription[src]

impl Ord for FontDescription[src]

impl PartialEq<FontDescription> for FontDescription[src]

impl PartialOrd<FontDescription> for FontDescription[src]

impl StaticType for FontDescription

Auto Trait Implementations

impl RefUnwindSafe for FontDescription

impl !Send for FontDescription

impl !Sync for FontDescription

impl Unpin for FontDescription

impl UnwindSafe for FontDescription

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.