Struct pango::FontDescription
source · 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
impl FontDescription
sourcepub fn as_ptr(&self) -> *mut PangoFontDescription
pub fn as_ptr(&self) -> *mut PangoFontDescription
Return the inner pointer to the underlying C value.
sourcepub unsafe fn from_glib_ptr_borrow<'a>(
ptr: *const *const PangoFontDescription
) -> &'a Self
pub unsafe fn from_glib_ptr_borrow<'a>( ptr: *const *const PangoFontDescription ) -> &'a Self
Borrows the underlying C value.
sourcepub unsafe fn from_glib_ptr_borrow_mut<'a>(
ptr: *mut *mut PangoFontDescription
) -> &'a mut Self
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
impl FontDescription
sourcepub fn new() -> FontDescription
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()
.
sourcepub fn better_match(
&self,
old_match: Option<&FontDescription>,
new_match: &FontDescription
) -> bool
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
Returns
true
if @new_match is a better match
sourcepub fn family(&self) -> Option<GString>
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.
sourcepub fn gravity(&self) -> Gravity
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.
sourcepub fn set_fields(&self) -> FontMask
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.
sourcepub fn size(&self) -> i32
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.
sourcepub fn is_size_absolute(&self) -> bool
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.
sourcepub fn stretch(&self) -> Stretch
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.
sourcepub fn style(&self) -> Style
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.
sourcepub fn variant(&self) -> Variant
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.
sourcepub fn variations(&self) -> Option<GString>
Available on crate feature v1_42
only.
pub fn variations(&self) -> Option<GString>
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.
sourcepub fn weight(&self) -> Weight
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.
sourcepub fn merge(
&mut self,
desc_to_merge: Option<&FontDescription>,
replace_existing: bool
)
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.
sourcepub fn set_absolute_size(&mut self, size: f64)
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.
sourcepub fn set_family(&mut self, family: &str)
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.
sourcepub fn set_gravity(&mut self, gravity: Gravity)
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.
sourcepub fn set_size(&mut self, size: i32)
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.
sourcepub fn set_stretch(&mut self, stretch: Stretch)
pub fn set_stretch(&mut self, stretch: Stretch)
sourcepub fn set_style(&mut self, style: Style)
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
sourcepub fn set_variant(&mut self, variant: Variant)
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.
sourcepub fn set_variations(&mut self, variations: Option<&str>)
Available on crate feature v1_42
only.
pub fn set_variations(&mut self, variations: Option<&str>)
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
sourcepub fn set_variations_static(&mut self, variations: &str)
Available on crate feature v1_42
only.
pub fn set_variations_static(&mut self, variations: &str)
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
sourcepub fn set_weight(&mut self, weight: Weight)
pub fn set_weight(&mut self, weight: Weight)
sourcepub fn to_filename(&self) -> Option<GString>
pub fn to_filename(&self) -> Option<GString>
sourcepub fn to_str(&self) -> GString
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().
sourcepub fn unset_fields(&mut self, to_unset: FontMask)
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.
sourcepub fn from_string(str: &str) -> FontDescription
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
impl Clone for FontDescription
source§impl Debug for FontDescription
impl Debug for FontDescription
source§impl Default for FontDescription
impl Default for FontDescription
source§impl Display for FontDescription
impl Display for FontDescription
source§impl From<FontDescription> for Value
impl From<FontDescription> for Value
source§fn from(o: FontDescription) -> Self
fn from(o: FontDescription) -> Self
source§impl HasParamSpec for FontDescription
impl HasParamSpec for FontDescription
type ParamSpec = ParamSpecBoxed
§type SetValue = FontDescription
type SetValue = FontDescription
type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, FontDescription>
fn param_spec_builder() -> Self::BuilderFn
source§impl Hash for FontDescription
impl Hash for FontDescription
source§impl Ord for FontDescription
impl Ord for FontDescription
source§fn cmp(&self, other: &FontDescription) -> Ordering
fn cmp(&self, other: &FontDescription) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for FontDescription
impl PartialEq for FontDescription
source§impl PartialOrd for FontDescription
impl PartialOrd for FontDescription
source§fn partial_cmp(&self, other: &FontDescription) -> Option<Ordering>
fn partial_cmp(&self, other: &FontDescription) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for FontDescription
impl StaticType for FontDescription
source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for FontDescription
impl Send for FontDescription
impl Sync for FontDescription
Auto Trait Implementations§
impl RefUnwindSafe for FontDescription
impl Unpin for FontDescription
impl UnwindSafe for FontDescription
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
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>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
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>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
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>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
source§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
source§fn ensure_type()
fn ensure_type()
source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.