2.13 <PangoFontDescription>

Structure: <PangoFontDescription>

A <PangoFontDescription> describes a font in an implementation-independent manner.

<PangoFontDescription> structures are used both to list what fonts are available on the system and also for specifying the characteristics of a font to load.

Procedures

Method: font-description:better-match? self old-match new-match ⇒ %return
Method: better-match? self old-match new-match ⇒ %return

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 #f, 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 oblique and italic as matches, but not as good a match as when the styles are equal.

Note that old-match must match self.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

old-match

Passed: a <PangoFontDescription>, or #f.

a <PangoFontDescription>, or #f

new-match

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a boolean.

#t if new-match is a better match

Method: font-description:copy self ⇒ %return
Method: copy self ⇒ %return

Make a copy of a <PangoFontDescription>.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>, may be #f

%return

Returned: a <PangoFontDescription>, or #f.

the newly allocated <PangoFontDescription>, which should be freed with font-description:free, or #f if self was #f.

Method: font-description:copy-static self ⇒ %return
Method: copy-static self ⇒ %return

Make a copy of a <PangoFontDescription>, but don’t duplicate allocated fields.

This is like font-description:copy, but only a shallow copy is made of the family name and other allocated fields. The result can only be used until self is modified or freed. This is meant to be used when the copy is only needed temporarily.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>, may be #f

%return

Returned: a <PangoFontDescription>, or #f.

the newly allocated <PangoFontDescription>, which should be freed with font-description:free, or #f if self was #f.

Method: font-description:equal? self desc2 ⇒ %return
Method: equal? self desc2 ⇒ %return

Compares two font descriptions for equality.

Two font descriptions are considered equal if the fonts they describe are provably identical. This means that their masks do not have to match, as long as other fields are all the same. (Two font descriptions may result in identical fonts being loaded, but still compare #f.)

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

desc2

Passed: a <PangoFontDescription>.

another <PangoFontDescription>

%return

Returned: a boolean.

#t if the two font descriptions are identical, #f otherwise.

Method: font-description:free self
Method: free self

Frees a font description.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>, may be #f

Procedure: font-description:from-string str ⇒ %return

Creates a new font description from a string representation.

The string must have the form

[FAMILY-LIST] [STYLE-OPTIONS] [SIZE] [VARIATIONS] [FEATURES]

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.

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

The following words are understood as variants: "Small-Caps", "All-Small-Caps", "Petite-Caps", "All-Petite-Caps", "Unicase", "Title-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".

The following words are understood as color values: "With-Color", "Without-Color".

VARIATIONS is a comma-separated list of font variations of the form @‍axis1=value,axis2=value,...

FEATURES is a comma-separated list of font features of the form \#‍feature1=value,feature2=value,... The =value part can be ommitted if the value is 1.

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 #f. 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 #‍tnum=1

str

Passed: a string.

string representation of a font description.

%return

Returned: a <PangoFontDescription>.

a new <PangoFontDescription>.

Method: font-description:get-color self ⇒ %return
Method: get-color self ⇒ %return

Returns the color field of the font description.

This field determines whether the font description should match fonts that have color glyphs, or fonts that don’t.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a <PangoFontColor>.

Method: font-description:get-family self ⇒ %return
Method: get-family self ⇒ %return

Gets the family name field of a font description.

See font-description:set-family.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

%return

Returned: a string, or #f.

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

Method: font-description:get-features self ⇒ %return
Method: get-features self ⇒ %return

Gets the features field of a font description.

See font-description:set-features.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a string, or #f.

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

Method: font-description:get-gravity self ⇒ %return
Method: get-gravity self ⇒ %return

Gets the gravity field of a font description.

See font-description:set-gravity.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a <PangoGravity>.

the gravity field for the font description. Use font-description:get-set-fields to find out if the field was explicitly set or not.

Method: font-description:get-set-fields self ⇒ %return
Method: get-set-fields self ⇒ %return

Determines which fields in a font description have been set.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a <PangoFontMask>.

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

Method: font-description:get-size self ⇒ %return
Method: get-size self ⇒ %return

Gets the size field of a font description.

See font-description:set-size.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a 32-bit integer.

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

Method: font-description:get-size-is-absolute? self ⇒ %return
Method: get-size-is-absolute? self ⇒ %return

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

See font-description:set-size and font-description:set-absolute-size.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a boolean.

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

Method: font-description:get-stretch self ⇒ %return
Method: get-stretch self ⇒ %return

Gets the stretch field of a font description.

See font-description:set-stretch.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

%return

Returned: a <PangoStretch>.

the stretch field for the font description. Use font-description:get-set-fields to find out if the field was explicitly set or not.

Method: font-description:get-style self ⇒ %return
Method: get-style self ⇒ %return

Gets the style field of a <PangoFontDescription>.

See font-description:set-style.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a <PangoStyle>.

the style field for the font description. Use font-description:get-set-fields to find out if the field was explicitly set or not.

Method: font-description:get-variant self ⇒ %return
Method: get-variant self ⇒ %return

Gets the variant field of a <PangoFontDescription>.

See font-description:set-variant.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

%return

Returned: a <PangoVariant>.

the variant field for the font description. Use font-description:get-set-fields to find out if the field was explicitly set or not.

Method: font-description:get-variations self ⇒ %return
Method: get-variations self ⇒ %return

Gets the variations field of a font description.

See font-description:set-variations.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a string, or #f.

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

Method: font-description:get-weight self ⇒ %return
Method: get-weight self ⇒ %return

Gets the weight field of a font description.

See font-description:set-weight.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a <PangoWeight>.

the weight field for the font description. Use font-description:get-set-fields to find out if the field was explicitly set or not.

Method: font-description:hash self ⇒ %return
Method: hash self ⇒ %return

Computes a hash of a <PangoFontDescription> structure.

This is suitable to be used, for example, as an argument to g_hash_table_new(). The hash value is independent of self->mask.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: an unsigned 32-bit integer.

the hash value.

Method: font-description:merge self desc-to-merge replace-existing
Method: merge self desc-to-merge replace-existing

Merges the fields that are set in desc-to-merge into the fields in self.

If replace-existing is #f, only fields in self that are not already set are affected. If #t, then fields that are already set will be replaced as well.

If desc-to-merge is #f, this function performs nothing.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

desc-to-merge

Passed: a <PangoFontDescription>, or #f.

the <PangoFontDescription> to merge from, or #f

replace-existing

Passed: a boolean.

if #t, replace fields in self with the corresponding values from desc-to-merge, even if they are already exist.

Method: font-description:merge-static self desc-to-merge replace-existing
Method: merge-static self desc-to-merge replace-existing

Merges the fields that are set in desc-to-merge into the fields in self, without copying allocated fields.

This is like font-description:merge, but only a shallow copy is made of the family name and other allocated fields. self can only be used until desc-to-merge is modified or freed. This is meant to be used when the merged font description is only needed temporarily.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

desc-to-merge

Passed: a <PangoFontDescription>.

the <PangoFontDescription> to merge from

replace-existing

Passed: a boolean.

if #t, replace fields in self with the corresponding values from desc-to-merge, even if they are already exist.

Procedure: font-description:new ⇒ %return

Creates a new font description structure with all fields unset.

%return

Returned: a <PangoFontDescription>.

the newly allocated <PangoFontDescription>, which should be freed using font-description:free.

Method: font-description:set-absolute-size self size
Method: set-absolute-size self size

Sets the size field of a font description, in device units.

This is mutually exclusive with font-description:set-size which sets the font size in points.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

size

Passed: a real number.

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.

Method: font-description:set-color self color
Method: set-color self color

Sets the color field of a font description.

This field determines whether the font description should match fonts that have color glyphs, or fonts that don’t.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

color

Passed: a <PangoFontColor>, or one of its symbols.

the <PangoFontColor> value

Method: font-description:set-family self family
Method: set-family self family

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 <PangoFontFamily>. In some uses of <PangoFontDescription>, it is also possible to use a comma separated list of family names for this field.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

family

Passed: a string.

a string representing the family name.

Method: font-description:set-family-static self family
Method: set-family-static self family

Sets the family name field of a font description, without copying the string.

This is like font-description:set-family, except that no copy of family 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 family is a static string such as a C string literal, or if self is only needed temporarily.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

family

Passed: a string.

a string representing the family name

Method: font-description:set-features self [features]
Method: set-features self [features]

Sets the features field of a font description.

OpenType font features allow to enable or disable certain optional features of a font, such as tabular numbers.

The format of the features string is comma-separated list of feature assignments, with each assignment being one of these forms:

FEATURE=n

where FEATURE must be a 4 character tag that identifies and OpenType feature, and n an integer (depending on the feature, the allowed values may be 0, 1 or bigger numbers). Unknown features are ignored.

Note that font features set in this way are enabled for the entire text that is using the font, which is not appropriate for all OpenType features. The intended use case is to select character variations (features cv01 - c99), style sets (ss01 - ss20) and the like.

Pango does not currently have a way to find supported OpenType features of a font. Both harfbuzz and freetype have API for this. See for example hb_ot_layout_table_get_feature_tags.

Features that are not supported by the font are silently ignored.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

features

Passed, or left out: a string, or #f.

a string representing the features

Method: font-description:set-features-static self features
Method: set-features-static self features

Sets the features field of a font description.

This is like font-description:set-features, except that no copy of featuresis 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 features is a static string such as a C string literal, or if self is only needed temporarily.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

features

Passed: a string.

a string representing the features

Method: font-description:set-gravity self gravity
Method: set-gravity self gravity

Sets the gravity field of a font description.

The gravity field specifies how the glyphs should be rotated. If gravity is 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 <PangoContext>.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

gravity

Passed: a <PangoGravity>, or one of its symbols.

the gravity for the font description.

Method: font-description:set-size self size
Method: set-size self size

Sets the size field of a font description in fractional points.

This is mutually exclusive with font-description:set-absolute-size.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

size

Passed: a 32-bit integer.

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 font-description:set-absolute-size if you need a particular size in device units.

Method: font-description:set-stretch self stretch
Method: set-stretch self stretch

Sets the stretch field of a font description.

The <PangoStretch> field specifies how narrow or wide the font should be.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

stretch

Passed: a <PangoStretch>, or one of its symbols.

the stretch for the font description

Method: font-description:set-style self style
Method: set-style self style

Sets the style field of a <PangoFontDescription>.

The <PangoStyle> enumeration describes whether the font is slanted and the manner in which it is slanted; it can be either normal, italic, or 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.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

style

Passed: a <PangoStyle>, or one of its symbols.

the style for the font description

Method: font-description:set-variant self variant
Method: set-variant self variant

Sets the variant field of a font description.

The <PangoVariant> can either be normal or small-caps.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

variant

Passed: a <PangoVariant>, or one of its symbols.

the variant type for the font description.

Method: font-description:set-variations self [variations]
Method: set-variations self [variations]

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 and freetype have API for this. See for example hb_ot_var_get_axis_infos.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>.

variations

Passed, or left out: a string, or #f.

a string representing the variations

Method: font-description:set-variations-static self variations
Method: set-variations-static self variations

Sets the variations field of a font description.

This is like font-description: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.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

variations

Passed: a string.

a string representing the variations

Method: font-description:set-weight self weight
Method: set-weight self weight

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 <PangoWeight> enumeration, other intermediate numeric values are possible.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

weight

Passed: a <PangoWeight>, or one of its symbols.

the weight for the font description.

Method: font-description:to-filename self ⇒ %return
Method: to-filename self ⇒ %return

Creates a filename representation of a font description.

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

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a string, or #f.

a new string that must be freed with byte-array:free.

Method: font-description:to-string self ⇒ %return
Method: to-string self ⇒ %return

Creates a string representation of a font description.

See font-description:from-string for a description of the format of the string representation. The family list in the string description will only have a terminating comma if the last word of the list is a valid style option.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

%return

Returned: a string.

a new string that must be freed with byte-array:free.

Method: font-description:unset-fields self to-unset
Method: unset-fields self to-unset

Unsets some of the fields in a <PangoFontDescription>.

The unset fields will get back to their default values.

self

Passed: a <PangoFontDescription>.

a <PangoFontDescription>

to-unset

Passed: a <PangoFontMask>, or a list of its symbols, or one of them.

bitmask of fields in the self to unset.