Struct pango::FontDescription[][src]

pub struct FontDescription(_);
Expand description

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

Creates a new font description structure with all fields unset.

Returns

the newly allocated FontDescription, which should be freed using pango_font_description_free().

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

Gets the family name field of a font description. See 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.

Gets the gravity field of a font description. See set_gravity().

Returns

the gravity field for the font description. Use set_fields() to find out if the field was explicitly set or not.

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.

Gets the size field of a font description. See set_size().

Returns

the size field for the font description in points or device units. You must call is_size_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 set_fields() to find out if the field was explicitly set or not.

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

Returns

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

Gets the stretch field of a font description. See set_stretch().

Returns

the stretch field for the font description. Use set_fields() to find out if the field was explicitly set or not.

Gets the style field of a FontDescription. See set_style().

Returns

the style field for the font description. Use set_fields() to find out if the field was explicitly set or not.

Gets the variant field of a FontDescription. See set_variant().

Returns

the variant field for the font description. Use set_fields() to find out if the field was explicitly set or not.

This is supported on crate feature v1_42 only.

Gets the variations field of a font description. See set_variations().

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.

Gets the weight field of a font description. See set_weight().

Returns

the weight field for the font description. Use set_fields() to find out if the field was explicitly set or not.

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.

Sets the size field of a font description, in device units. This is mutually exclusive with 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.

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.

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.

Sets the size field of a font description in fractional points. This is mutually exclusive with 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 set_absolute_size() if you need a particular size in device units.

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

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

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.

This is supported on crate feature v1_42 only.

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.

variations

a string representing the variations

This is supported on crate feature v1_42 only.

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

variations

a string representing the variations

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.

Creates a filename representation of a font description. The filename is identical to the result from calling to_str(), 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().

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.