FontDescriptionProtocol
public protocol FontDescriptionProtocol
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.
The FontDescriptionProtocol
protocol exposes the methods and properties of an underlying PangoFontDescription
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see FontDescription
.
Alternatively, use FontDescriptionRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
PangoFontDescription
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
font_description_ptr
Default implementationTyped pointer to the underlying
PangoFontDescription
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
PangoFontDescription
instance.Declaration
Swift
var font_description_ptr: UnsafeMutablePointer<PangoFontDescription>! { get }
-
Required Initialiser for types conforming to
FontDescriptionProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
betterMatch(oldMatch:
Extension methodnewMatch: ) Determines if the style attributes of
new_match
are a closer match fordesc
than those ofold_match
are, or ifold_match
isnil
, determines ifnew_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
andPANGO_STYLE_ITALIC
as matches, but not as good a match as when the styles are equal.Note that
old_match
must matchdesc
.Declaration
Swift
@inlinable func betterMatch<FontDescriptionT>(oldMatch: FontDescriptionT?, newMatch: FontDescriptionT) -> Bool where FontDescriptionT : FontDescriptionProtocol
-
copy()
Extension methodMake a copy of a
PangoFontDescription
.Declaration
Swift
@inlinable func copy() -> Pango.FontDescriptionRef!
-
copyStatic()
Extension methodMake a copy of a
PangoFontDescription
, but don’t duplicate allocated fields.This is like [method
Pango.FontDescription.copy
], but only a shallow copy is made of the family name and other allocated fields. The result can only be used untildesc
is modified or freed. This is meant to be used when the copy is only needed temporarily.Declaration
Swift
@inlinable func copyStatic() -> Pango.FontDescriptionRef!
-
equal(desc2:
Extension method) 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
false
.)Declaration
Swift
@inlinable func equal<FontDescriptionT>(desc2: FontDescriptionT) -> Bool where FontDescriptionT : FontDescriptionProtocol
-
free()
Extension methodFrees a font description.
Declaration
Swift
@inlinable func free()
-
getFamily()
Extension methodGets the family name field of a font description.
See [method
Pango.FontDescription.set_family
].Declaration
Swift
@inlinable func getFamily() -> String!
-
getGravity()
Extension methodGets the gravity field of a font description.
See [method
Pango.FontDescription.set_gravity
].Declaration
Swift
@inlinable func getGravity() -> PangoGravity
-
getSetFields()
Extension methodDetermines which fields in a font description have been set.
Declaration
Swift
@inlinable func getSetFields() -> Pango.FontMask
-
getSize()
Extension methodGets the size field of a font description.
See [method
Pango.FontDescription.set_size
].Declaration
Swift
@inlinable func getSize() -> Int
-
getSizeIsAbsolute()
Extension methodDetermines whether the size of the font is in points (not absolute) or device units (absolute).
See [method
Pango.FontDescription.set_size
] and [methodPango.FontDescription.set_absolute_size
].Declaration
Swift
@inlinable func getSizeIsAbsolute() -> Bool
-
getStretch()
Extension methodGets the stretch field of a font description.
See [method
Pango.FontDescription.set_stretch
].Declaration
Swift
@inlinable func getStretch() -> PangoStretch
-
getStyle()
Extension methodGets the style field of a
PangoFontDescription
.See [method
Pango.FontDescription.set_style
].Declaration
Swift
@inlinable func getStyle() -> PangoStyle
-
getVariant()
Extension methodGets the variant field of a
PangoFontDescription
.See [method
Pango.FontDescription.set_variant
].Declaration
Swift
@inlinable func getVariant() -> PangoVariant
-
getVariations()
Extension methodGets the variations field of a font description.
See [method
Pango.FontDescription.set_variations
].Declaration
Swift
@inlinable func getVariations() -> String!
-
getWeight()
Extension methodGets the weight field of a font description.
See [method
Pango.FontDescription.set_weight
].Declaration
Swift
@inlinable func getWeight() -> PangoWeight
-
hash()
Extension methodComputes 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 ofdesc-
>mask.Declaration
Swift
@inlinable func hash() -> Int
-
merge(descToMerge:
Extension methodreplaceExisting: ) Merges the fields that are set in
desc_to_merge
into the fields indesc
.If
replace_existing
isfalse
, only fields indesc
that are not already set are affected. Iftrue
, then fields that are already set will be replaced as well.If
desc_to_merge
isnil
, this function performs nothing.Declaration
Swift
@inlinable func merge(descToMerge: FontDescriptionRef? = nil, replaceExisting: Bool)
-
merge(descToMerge:
Extension methodreplaceExisting: ) Merges the fields that are set in
desc_to_merge
into the fields indesc
.If
replace_existing
isfalse
, only fields indesc
that are not already set are affected. Iftrue
, then fields that are already set will be replaced as well.If
desc_to_merge
isnil
, this function performs nothing.Declaration
Swift
@inlinable func merge<FontDescriptionT>(descToMerge: FontDescriptionT?, replaceExisting: Bool) where FontDescriptionT : FontDescriptionProtocol
-
mergeStatic(descToMerge:
Extension methodreplaceExisting: ) Merges the fields that are set in
desc_to_merge
into the fields indesc
, without copying allocated fields.This is like [method
Pango.FontDescription.merge
], but only a shallow copy is made of the family name and other allocated fields.desc
can only be used untildesc_to_merge
is modified or freed. This is meant to be used when the merged font description is only needed temporarily.Declaration
Swift
@inlinable func mergeStatic<FontDescriptionT>(descToMerge: FontDescriptionT, replaceExisting: Bool) where FontDescriptionT : FontDescriptionProtocol
-
setAbsolute(size:
Extension method) Sets the size field of a font description, in device units.
This is mutually exclusive with [method
Pango.FontDescription.set_size
] which sets the font size in points.Declaration
Swift
@inlinable func setAbsolute(size: CDouble)
-
set(family:
Extension method) 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 ofPangoFontDescription
, it is also possible to use a comma separated list of family names for this field.Declaration
Swift
@inlinable func set(family: UnsafePointer<CChar>!)
-
setFamilyStatic(family:
Extension method) Sets the family name field of a font description, without copying the string.
This is like [method
Pango.FontDescription.set_family
], except that no copy offamily
is made. The caller must make sure that the string passed in stays around untildesc
has been freed or the name is set again. This function can be used iffamily
is a static string such as a C string literal, or ifdesc
is only needed temporarily.Declaration
Swift
@inlinable func setFamilyStatic(family: UnsafePointer<CChar>!)
-
set(gravity:
Extension method) Sets the gravity field of a font description.
The gravity field specifies how the glyphs should be rotated. If
gravity
isPANGO_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
PangoContext
.Declaration
Swift
@inlinable func set(gravity: PangoGravity)
-
set(size:
Extension method) Sets the size field of a font description in fractional points.
This is mutually exclusive with [method
Pango.FontDescription.set_absolute_size
].Declaration
Swift
@inlinable func set(size: Int)
-
set(stretch:
Extension method) Sets the stretch field of a font description.
The [enum
Pango.Stretch
] field specifies how narrow or wide the font should be.Declaration
Swift
@inlinable func set(stretch: PangoStretch)
-
set(style:
Extension method) Sets the style field of a
PangoFontDescription
.The [enum
Pango.Style
] enumeration describes whether the font is slanted and the manner in which it is slanted; it can be eitherPANGO_STYLE_NORMAL
,PANGO_STYLE_ITALIC
, orPANGO_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.
Declaration
Swift
@inlinable func set(style: PangoStyle)
-
set(variant:
Extension method) Sets the variant field of a font description.
The [enum
Pango.Variant
] can either bePANGO_VARIANT_NORMAL
orPANGO_VARIANT_SMALL_CAPS
.Declaration
Swift
@inlinable func set(variant: PangoVariant)
-
set(variations:
Extension method) 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.
Declaration
Swift
@inlinable func set(variations: UnsafePointer<CChar>? = nil)
-
setVariationsStatic(variations:
Extension method) Sets the variations field of a font description.
This is like [method
Pango.FontDescription.set_variations
], except that no copy ofvariations
is made. The caller must make sure that the string passed in stays around untildesc
has been freed or the name is set again. This function can be used ifvariations
is a static string such as a C string literal, or ifdesc
is only needed temporarily.Declaration
Swift
@inlinable func setVariationsStatic(variations: UnsafePointer<CChar>!)
-
set(weight:
Extension method) 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 [enum
Pango.Weight
] enumeration, other intermediate numeric values are possible.Declaration
Swift
@inlinable func set(weight: PangoWeight)
-
toFilename()
Extension methodCreates a filename representation of a font description.
The filename is identical to the result from calling [method
Pango.FontDescription.to_string
], but with underscores instead of characters that are untypical in filenames, and in lower case only.Declaration
Swift
@inlinable func toFilename() -> String!
-
toString()
Extension methodCreates a string representation of a font description.
See [func
Pango.FontDescription.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.Declaration
Swift
@inlinable func toString() -> String!
-
unsetFields(toUnset:
Extension method) Unsets some of the fields in a
PangoFontDescription
.The unset fields will get back to their default values.
Declaration
Swift
@inlinable func unsetFields(toUnset: FontMask)
-
attrFontDescNew()
Extension methodCreate a new font description attribute.
This attribute allows setting family, style, weight, variant, stretch, and size simultaneously.
Declaration
Swift
@inlinable func attrFontDescNew() -> Pango.AttributeRef!
-
family
Extension methodGets the family name field of a font description.
See [method
Pango.FontDescription.set_family
].Declaration
Swift
@inlinable var family: String! { get nonmutating set }
-
gravity
Extension methodGets the gravity field of a font description.
See [method
Pango.FontDescription.set_gravity
].Declaration
Swift
@inlinable var gravity: PangoGravity { get nonmutating set }
-
setFields
Extension methodDetermines which fields in a font description have been set.
Declaration
Swift
@inlinable var setFields: Pango.FontMask { get }
-
size
Extension methodGets the size field of a font description.
See [method
Pango.FontDescription.set_size
].Declaration
Swift
@inlinable var size: Int { get nonmutating set }
-
sizeIsAbsolute
Extension methodDetermines whether the size of the font is in points (not absolute) or device units (absolute).
See [method
Pango.FontDescription.set_size
] and [methodPango.FontDescription.set_absolute_size
].Declaration
Swift
@inlinable var sizeIsAbsolute: Bool { get }
-
stretch
Extension methodGets the stretch field of a font description.
See [method
Pango.FontDescription.set_stretch
].Declaration
Swift
@inlinable var stretch: PangoStretch { get nonmutating set }
-
style
Extension methodGets the style field of a
PangoFontDescription
.See [method
Pango.FontDescription.set_style
].Declaration
Swift
@inlinable var style: PangoStyle { get nonmutating set }
-
variant
Extension methodGets the variant field of a
PangoFontDescription
.See [method
Pango.FontDescription.set_variant
].Declaration
Swift
@inlinable var variant: PangoVariant { get nonmutating set }
-
variations
Extension methodGets the variations field of a font description.
See [method
Pango.FontDescription.set_variations
].Declaration
Swift
@inlinable var variations: String! { get nonmutating set }
-
weight
Extension methodGets the weight field of a font description.
See [method
Pango.FontDescription.set_weight
].Declaration
Swift
@inlinable var weight: PangoWeight { get nonmutating set }