Struct pango::FontDescription

source ·
#[repr(transparent)]
pub struct FontDescription { /* private fields */ }
Expand description

A FontDescription describes a font in an implementation-independent manner.

FontDescription 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§

source§

impl FontDescription

source

pub fn as_ptr(&self) -> *mut PangoFontDescription

Return the inner pointer to the underlying C value.

source

pub unsafe fn from_glib_ptr_borrow<'a>( ptr: *const *const PangoFontDescription ) -> &'a Self

Borrows the underlying C value.

source

pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut *mut PangoFontDescription ) -> &'a mut Self

Borrows the underlying C value mutably.

source§

impl FontDescription

source

pub fn new() -> FontDescription

Creates a new font description structure with all fields unset.

Returns

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

source

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

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 Style::Oblique and 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

source

pub fn family(&self) -> Option<GString>

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.

source

pub fn gravity(&self) -> Gravity

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.

source

pub fn set_fields(&self) -> FontMask

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.

source

pub fn size(&self) -> i32

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.

source

pub fn is_size_absolute(&self) -> bool

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.

source

pub fn stretch(&self) -> Stretch

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.

source

pub fn style(&self) -> Style

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.

source

pub fn variant(&self) -> Variant

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.

source

pub fn variations(&self) -> Option<GString>

Available on crate feature v1_42 only.

Gets the variations field of a font description.

See set_variations().

Returns

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

source

pub fn weight(&self) -> Weight

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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

source

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

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

source

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

Sets the variant field of a font description.

The [Variant][struct@crate::Variant] can either be Variant::Normal or Variant::SmallCaps.

variant

the variant type for the font description.

source

pub fn set_variations(&mut self, variations: Option<&str>)

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

variations

a string representing the variations

source

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

Available on crate feature v1_42 only.

Sets the variations field of a font description.

This is 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

source

pub fn set_weight(&mut self, weight: 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 Weight enumeration, other intermediate numeric values are possible.

weight

the weight for the font description.

source

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

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

source

pub fn to_str(&self) -> GString

Creates a string representation of a font description.

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

Returns

a new string that must be freed with g_free().

source

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

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.

source

pub fn from_string(str: &str) -> FontDescription

Creates a new font description from a string representation.

The string must have 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”, “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”.

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§

source§

impl Clone for FontDescription

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FontDescription

source§

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

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

impl Default for FontDescription

source§

fn default() -> Self

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

impl Display for FontDescription

source§

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

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

impl From<FontDescription> for Value

source§

fn from(o: FontDescription) -> Self

Converts to this type from the input type.
source§

impl HasParamSpec for FontDescription

§

type ParamSpec = ParamSpecBoxed

§

type SetValue = FontDescription

Preferred value to be used as setter for the associated ParamSpec.
§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, FontDescription>

source§

fn param_spec_builder() -> Self::BuilderFn

source§

impl Hash for FontDescription

source§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

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

impl Ord for FontDescription

source§

fn cmp(&self, other: &FontDescription) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<FontDescription> for FontDescription

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<FontDescription> for FontDescription

source§

fn partial_cmp(&self, other: &FontDescription) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

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

fn le(&self, other: &Rhs) -> bool

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

fn gt(&self, other: &Rhs) -> bool

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

fn ge(&self, other: &Rhs) -> bool

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

impl StaticType for FontDescription

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl Eq for FontDescription

source§

impl Send for FontDescription

source§

impl Sync for FontDescription

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

impl<T, U> Into<U> for Twhere 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> IntoClosureReturnValue for Twhere T: Into<Value>,

source§

impl<T> Property for Twhere T: HasParamSpec,

§

type Value = T

source§

impl<T> PropertyGet for Twhere T: HasParamSpec,

§

type Value = T

source§

fn get<R, F>(&self, f: F) -> Rwhere F: Fn(&<T as PropertyGet>::Value) -> R,

source§

impl<T> StaticTypeExt for Twhere T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToSendValue for Twhere T: Send + ToValue + ?Sized,

source§

fn to_send_value(&self) -> SendValue

Returns a SendValue clone of self.
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> TransparentType for Twhere T: TransparentPtrType,

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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> TryFromClosureReturnValue for Twhere T: for<'a> FromValue<'a> + StaticType + 'static,

source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

impl<'a, T, C, E> FromValueOptional<'a> for Twhere T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,