Functions
pango_attr_type_get_name ()
const char *
pango_attr_type_get_name (PangoAttrType type);
Fetches the attribute type name passed in when registering the type using
pango_attr_type_register().
The returned value is an interned string (see g_intern_string() for what
that means) that should not be modified or freed.
Returns
the type ID name (which may be NULL), or
NULL if type
is a built-in Pango attribute type or invalid.
[nullable]
Since: 1.22
pango_attribute_equal ()
gboolean
pango_attribute_equal (const PangoAttribute *attr1,
const PangoAttribute *attr2);
Compare two attributes for equality. This compares only the
actual value of the two attributes and not the ranges that the
attributes apply to.
Returns
TRUE if the two attributes have the same value.
pango_attr_family_new ()
PangoAttribute *
pango_attr_family_new (const char *family);
Create a new font family attribute.
pango_attr_style_new ()
PangoAttribute *
pango_attr_style_new (PangoStyle style);
Create a new font slant style attribute.
pango_attr_variant_new ()
PangoAttribute *
pango_attr_variant_new (PangoVariant variant);
Create a new font variant attribute (normal or small caps)
pango_attr_size_new ()
PangoAttribute *
pango_attr_size_new (int size);
Create a new font-size attribute in fractional points.
pango_attr_size_new_absolute ()
PangoAttribute *
pango_attr_size_new_absolute (int size);
Create a new font-size attribute in device units.
Since: 1.8
pango_attr_font_desc_new ()
PangoAttribute *
pango_attr_font_desc_new (const PangoFontDescription *desc);
Create a new font description attribute. This attribute
allows setting family, style, weight, variant, stretch,
and size simultaneously.
pango_attr_strikethrough_new ()
PangoAttribute *
pango_attr_strikethrough_new (gboolean strikethrough);
Create a new strike-through attribute.
pango_attr_strikethrough_color_new ()
PangoAttribute *
pango_attr_strikethrough_color_new (guint16 red,
guint16 green,
guint16 blue);
Create a new strikethrough color attribute. This attribute
modifies the color of strikethrough lines. If not set, strikethrough
lines will use the foreground color.
Since: 1.8
pango_attr_underline_color_new ()
PangoAttribute *
pango_attr_underline_color_new (guint16 red,
guint16 green,
guint16 blue);
Create a new underline color attribute. This attribute
modifies the color of underlines. If not set, underlines
will use the foreground color.
Since: 1.8
pango_attr_shape_new ()
PangoAttribute *
pango_attr_shape_new (const PangoRectangle *ink_rect,
const PangoRectangle *logical_rect);
Create a new shape attribute. A shape is used to impose a
particular ink and logical rectangle on the result of shaping a
particular glyph. This might be used, for instance, for
embedding a picture or a widget inside a PangoLayout.
PangoAttrDataCopyFunc ()
gpointer
(*PangoAttrDataCopyFunc) (gconstpointer user_data);
Type of a function that can duplicate user data for an attribute.
Returns
new copy of user_data
.
pango_attr_scale_new ()
PangoAttribute *
pango_attr_scale_new (double scale_factor);
Create a new font size scale attribute. The base font for the
affected text will have its size multiplied by scale_factor
.
pango_attr_rise_new ()
PangoAttribute *
pango_attr_rise_new (int rise);
Create a new baseline displacement attribute.
pango_attr_letter_spacing_new ()
PangoAttribute *
pango_attr_letter_spacing_new (int letter_spacing);
Create a new letter-spacing attribute.
Since: 1.6
pango_attr_fallback_new ()
PangoAttribute *
pango_attr_fallback_new (gboolean enable_fallback);
Create a new font fallback attribute.
If fallback is disabled, characters will only be used from the
closest matching font on the system. No fallback will be done to
other fonts on the system that might contain the characters in the
text.
Since: 1.4
pango_attr_font_features_new ()
PangoAttribute *
pango_attr_font_features_new (const gchar *features);
Create a new font features tag attribute.
Since: 1.38
pango_attr_foreground_alpha_new ()
PangoAttribute *
pango_attr_foreground_alpha_new (guint16 alpha);
Create a new foreground alpha attribute.
Since: 1.38
pango_attr_background_alpha_new ()
PangoAttribute *
pango_attr_background_alpha_new (guint16 alpha);
Create a new background alpha attribute.
Since: 1.38
pango_attr_allow_breaks_new ()
PangoAttribute *
pango_attr_allow_breaks_new (gboolean allow_breaks);
Create a new allow-breaks attribute.
If breaks are disabled, the range will be kept in a
single run, as far as possible.
Since: 1.44
pango_attr_insert_hyphens_new ()
PangoAttribute *
pango_attr_insert_hyphens_new (gboolean insert_hyphens);
Create a new insert-hyphens attribute.
Pango will insert hyphens when breaking lines in the middle
of a word. This attribute can be used to suppress the hyphen.
Since: 1.44
pango_attr_show_new ()
PangoAttribute *
pango_attr_show_new (PangoShowFlags flags);
Create a new attribute that influences how invisible
characters are rendered.
Since: 1.44
pango_color_parse ()
gboolean
pango_color_parse (PangoColor *color,
const char *spec);
Fill in the fields of a color from a string specification. The
string can either one of a large set of standard names. (Taken
from the CSS specification), or it can be a hexadecimal
value in the
form '#rgb' '#rrggbb' '#rrrgggbbb' or '#rrrrggggbbbb' where
'r', 'g' and 'b' are hex digits of the red, green, and blue
components of the color, respectively. (White in the four
forms is '#fff' '#ffffff' '#fffffffff' and '#ffffffffffff')
Returns
TRUE if parsing of the specifier succeeded,
otherwise false.
pango_color_copy ()
PangoColor *
pango_color_copy (const PangoColor *src);
Creates a copy of src
, which should be freed with
pango_color_free(). Primarily used by language bindings,
not that useful otherwise (since colors can just be copied
by assignment in C).
pango_color_to_string ()
gchar *
pango_color_to_string (const PangoColor *color);
Returns a textual specification of color
in the hexadecimal form
#rrrrggggbbbb, where r,
g and b are hex digits representing
the red, green, and blue components respectively.
Returns
a newly-allocated text string that must be freed with g_free().
Since: 1.16
pango_attr_list_new ()
PangoAttrList *
pango_attr_list_new (void);
Create a new empty attribute list with a reference count of one.
pango_attr_list_ref ()
PangoAttrList *
pango_attr_list_ref (PangoAttrList *list);
Increase the reference count of the given attribute list by one.
Returns
The attribute list passed in
Since: 1.10
pango_attr_list_unref ()
void
pango_attr_list_unref (PangoAttrList *list);
Decrease the reference count of the given attribute list by one.
If the result is zero, free the attribute list and the attributes
it contains.
pango_attr_list_insert ()
void
pango_attr_list_insert (PangoAttrList *list,
PangoAttribute *attr);
Insert the given attribute into the PangoAttrList. It will
be inserted after all other attributes with a matching
start_index
.
pango_attr_list_insert_before ()
void
pango_attr_list_insert_before (PangoAttrList *list,
PangoAttribute *attr);
Insert the given attribute into the PangoAttrList. It will
be inserted before all other attributes with a matching
start_index
.
pango_attr_list_change ()
void
pango_attr_list_change (PangoAttrList *list,
PangoAttribute *attr);
Insert the given attribute into the PangoAttrList. It will
replace any attributes of the same type on that segment
and be merged with any adjoining attributes that are identical.
This function is slower than pango_attr_list_insert() for
creating a attribute list in order (potentially much slower
for large lists). However, pango_attr_list_insert() is not
suitable for continually changing a set of attributes
since it never removes or combines existing attributes.
pango_attr_list_splice ()
void
pango_attr_list_splice (PangoAttrList *list,
PangoAttrList *other,
gint pos,
gint len);
This function opens up a hole in list
, fills it in with attributes from
the left, and then merges other
on top of the hole.
This operation is equivalent to stretching every attribute
that applies at position pos
in list
by an amount len
,
and then calling pango_attr_list_change() with a copy
of each attribute in other
in sequence (offset in position by pos
).
This operation proves useful for, for instance, inserting
a pre-edit string in the middle of an edit buffer.
pango_attr_list_update ()
void
pango_attr_list_update (PangoAttrList *list,
int pos,
int remove,
int add);
Update indices of attributes in list
for
a change in the text they refer to.
The change that this function applies is
removing remove
bytes at position pos
and inserting add
bytes instead.
Attributes that fall entirely in the
(pos
, pos
+ remove
) range are removed.
Attributes that start or end inside the
(pos
, pos
+ remove
) range are shortened to
reflect the removal.
Attributes start and end positions are updated
if they are behind pos
+ remove
.
Since: 1.44
PangoAttrFilterFunc ()
gboolean
(*PangoAttrFilterFunc) (PangoAttribute *attribute,
gpointer user_data);
Type of a function filtering a list of attributes.
Returns
TRUE if the attribute should be selected for
filtering, FALSE otherwise.
pango_attr_list_get_attributes ()
GSList *
pango_attr_list_get_attributes (PangoAttrList *list);
Gets a list of all attributes in list
.
Since: 1.44
pango_attr_list_get_iterator ()
PangoAttrIterator *
pango_attr_list_get_iterator (PangoAttrList *list);
Create a iterator initialized to the beginning of the list.
list
must not be modified until this iterator is freed.
pango_attr_iterator_next ()
gboolean
pango_attr_iterator_next (PangoAttrIterator *iterator);
Advance the iterator until the next change of style.
Returns
FALSE if the iterator is at the end of the list, otherwise TRUE
pango_attr_iterator_range ()
void
pango_attr_iterator_range (PangoAttrIterator *iterator,
gint *start,
gint *end);
Get the range of the current segment. Note that the
stored return values are signed, not unsigned like
the values in PangoAttribute. To deal with this API
oversight, stored return values that wouldn't fit into
a signed integer are clamped to G_MAXINT.
pango_attr_iterator_get ()
PangoAttribute *
pango_attr_iterator_get (PangoAttrIterator *iterator,
PangoAttrType type);
Find the current attribute of a particular type at the iterator
location. When multiple attributes of the same type overlap,
the attribute whose range starts closest to the current location
is used.
Returns
the current attribute of the given type,
or NULL if no attribute of that type applies to the
current location.
[nullable]
pango_attr_iterator_get_attrs ()
GSList *
pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
Gets a list of all attributes at the current position of the
iterator.
Returns
a list of
all attributes for the current range.
To free this value, call pango_attribute_destroy() on
each value and g_slist_free() on the list.
[element-type Pango.Attribute][transfer full]
Since: 1.2
Types and Values
enum PangoAttrType
The PangoAttrType
distinguishes between different types of attributes. Along with the
predefined values, it is possible to allocate additional values
for custom attributes using pango_attr_type_register(). The predefined
values are given below. The type of structure used to store the
attribute is listed in parentheses after the description.
struct PangoAttrClass
struct PangoAttrClass {
PangoAttrType type;
PangoAttribute * (*copy) (const PangoAttribute *attr);
void (*destroy) (PangoAttribute *attr);
gboolean (*equal) (const PangoAttribute *attr1, const PangoAttribute *attr2);
};
The PangoAttrClass structure stores the type and operations for
a particular type of attribute. The functions in this structure should
not be called directly. Instead, one should use the wrapper functions
provided for PangoAttribute.
struct PangoAttribute
struct PangoAttribute {
const PangoAttrClass *klass;
guint start_index; /* in bytes */
guint end_index; /* in bytes. The character at this index is not included */
};
The PangoAttribute structure represents the common portions of all
attributes. Particular types of attributes include this structure
as their initial portion. The common portion of the attribute holds
the range to which the value in the type-specific part of the attribute
applies and should be initialized using pango_attribute_init().
By default an attribute will have an all-inclusive range of [0,G_MAXUINT].
PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING
#define PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING 0
This value can be used to set the start_index member of a PangoAttribute
such that the attribute covers from the beginning of the text.
Since: 1.24
PANGO_ATTR_INDEX_TO_TEXT_END
#define PANGO_ATTR_INDEX_TO_TEXT_END G_MAXUINT
This value can be used to set the end_index member of a PangoAttribute
such that the attribute covers to the end of the text.
Since: 1.24
struct PangoAttrString
struct PangoAttrString {
PangoAttribute attr;
char *value;
};
The PangoAttrString structure is used to represent attributes with
a string value.
struct PangoAttrLanguage
struct PangoAttrLanguage {
PangoAttribute attr;
PangoLanguage *value;
};
The PangoAttrLanguage structure is used to represent attributes that
are languages.
struct PangoAttrColor
struct PangoAttrColor {
PangoAttribute attr;
PangoColor color;
};
The PangoAttrColor structure is used to represent attributes that
are colors.
struct PangoAttrInt
struct PangoAttrInt {
PangoAttribute attr;
int value;
};
The PangoAttrInt structure is used to represent attributes with
an integer or enumeration value.
struct PangoAttrFloat
struct PangoAttrFloat {
PangoAttribute attr;
double value;
};
The PangoAttrFloat structure is used to represent attributes with
a float or double value.
struct PangoAttrFontDesc
struct PangoAttrFontDesc {
PangoAttribute attr;
PangoFontDescription *desc;
};
The PangoAttrFontDesc structure is used to store an attribute that
sets all aspects of the font description at once.
struct PangoAttrShape
struct PangoAttrShape {
PangoAttribute attr;
PangoRectangle ink_rect;
PangoRectangle logical_rect;
gpointer data;
PangoAttrDataCopyFunc copy_func;
GDestroyNotify destroy_func;
};
The PangoAttrShape structure is used to represent attributes which
impose shape restrictions.
struct PangoAttrSize
struct PangoAttrSize {
PangoAttribute attr;
int size;
guint absolute : 1;
};
The PangoAttrSize structure is used to represent attributes which
set font size.
struct PangoAttrFontFeatures
struct PangoAttrFontFeatures {
PangoAttribute attr;
gchar *features;
};
The PangoAttrFontFeatures structure is used to represent OpenType
font features as an attribute.
Since: 1.38
enum PangoUnderline
The PangoUnderline enumeration is used to specify
whether text should be underlined, and if so, the type
of underlining.
PANGO_SCALE_XX_SMALL
#define PANGO_SCALE_XX_SMALL ((double)0.5787037037037)
The scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)).
PANGO_SCALE_X_SMALL
#define PANGO_SCALE_X_SMALL ((double)0.6944444444444)
The scale factor for two shrinking steps (1 / (1.2 * 1.2)).
PANGO_SCALE_SMALL
#define PANGO_SCALE_SMALL ((double)0.8333333333333)
The scale factor for one shrinking step (1 / 1.2).
PANGO_SCALE_MEDIUM
#define PANGO_SCALE_MEDIUM ((double)1.0)
The scale factor for normal size (1.0).
PANGO_SCALE_LARGE
#define PANGO_SCALE_LARGE ((double)1.2)
The scale factor for one magnification step (1.2).
PANGO_SCALE_X_LARGE
#define PANGO_SCALE_X_LARGE ((double)1.44)
The scale factor for two magnification steps (1.2 * 1.2).
PANGO_SCALE_XX_LARGE
#define PANGO_SCALE_XX_LARGE ((double)1.728)
The scale factor for three magnification steps (1.2 * 1.2 * 1.2).
enum PangoShowFlags
These flags affect how Pango treats characters that are normally
not visible in the output.
struct PangoColor
struct PangoColor {
guint16 red;
guint16 green;
guint16 blue;
};
The PangoColor structure is used to
represent a color in an uncalibrated RGB color-space.
PangoAttrList
typedef struct _PangoAttrList PangoAttrList;
The PangoAttrList structure represents a list of attributes
that apply to a section of text. The attributes are, in general,
allowed to overlap in an arbitrary fashion, however, if the
attributes are manipulated only through pango_attr_list_change(),
the overlap between properties will meet stricter criteria.
Since the PangoAttrList structure is stored as a linear list,
it is not suitable for storing attributes for large amounts
of text. In general, you should not use a single PangoAttrList
for more than one paragraph of text.
PangoAttrIterator
typedef struct _PangoAttrIterator PangoAttrIterator;
The PangoAttrIterator structure is used to represent an
iterator through a PangoAttrList. A new iterator is created
with pango_attr_list_get_iterator(). Once the iterator
is created, it can be advanced through the style changes
in the text using pango_attr_iterator_next(). At each
style change, the range of the current style segment and the
attributes currently in effect can be queried.