Functions
pango_itemize ()
GList *
pango_itemize (PangoContext *context,
const char *text,
int start_index,
int length,
PangoAttrList *attrs,
PangoAttrIterator *cached_iter);
Breaks a piece of text into segments with consistent
directional level and shaping engine. Each byte of text
will
be contained in exactly one of the items in the returned list;
the generated list of items will be in logical order (the start
offsets of the items are ascending).
cached_iter
should be an iterator over attrs
currently positioned at a
range before or containing start_index
; cached_iter
will be advanced to
the range covering the position just after start_index
+ length
.
(i.e. if itemizing in a loop, just keep passing in the same cached_iter
).
pango_item_free ()
void
pango_item_free (PangoItem *item);
Free a PangoItem and all associated memory.
pango_item_new ()
PangoItem *
pango_item_new (void);
Creates a new PangoItem structure initialized to default values.
pango_item_split ()
PangoItem *
pango_item_split (PangoItem *orig,
int split_index,
int split_offset);
Modifies orig
to cover only the text after split_index
, and
returns a new item that covers the text before split_index
that
used to be in orig
. You can think of split_index
as the length of
the returned item. split_index
may not be 0, and it may not be
greater than or equal to the length of orig
(that is, there must
be at least one byte assigned to each item, you can't create a
zero-length item). split_offset
is the length of the first item in
chars, and must be provided because the text used to generate the
item isn't available, so pango_item_split() can't count the char
length of the split items itself.
Returns
new item representing text before split_index
, which
should be freed with pango_item_free().
pango_item_apply_attrs ()
void
pango_item_apply_attrs (PangoItem *item,
PangoAttrIterator *iter);
Add attributes to a PangoItem. The idea is that you have
attributes that don't affect itemization, such as font features,
so you filter them out using pango_attr_list_filter(), itemize
your text, then reapply the attributes to the resulting items
using this function.
The iter
should be positioned before the range of the item,
and will be advanced past it. This function is meant to be called
in a loop over the items resulting from itemization, while passing
the iter to each call.
Since: 1.44
pango_reorder_items ()
GList *
pango_reorder_items (GList *logical_items);
From a list of items in logical order and the associated
directional levels, produce a list in visual order.
The original list is unmodified.
Returns
a GList
of PangoItem structures in visual order.
(Please open a bug if you use this function.
It is not a particularly convenient interface, and the code
is duplicated elsewhere in Pango for that reason.).
[transfer full][element-type Pango.Item]
pango_break ()
void
pango_break (const gchar *text,
int length,
PangoAnalysis *analysis,
PangoLogAttr *attrs,
int attrs_len);
Determines possible line, word, and character breaks
for a string of Unicode text with a single analysis.
For most purposes you may want to use pango_get_log_attrs().
pango_get_log_attrs ()
void
pango_get_log_attrs (const char *text,
int length,
int level,
PangoLanguage *language,
PangoLogAttr *log_attrs,
int attrs_len);
Computes a PangoLogAttr for each character in text
. The log_attrs
array must have one PangoLogAttr for each position in text
; if
text
contains N characters, it has N+1 positions, including the
last position at the end of the text. text
should be an entire
paragraph; logical attributes can't be computed without context
(for example you need to see spaces on either side of a word to know
the word is a word).
pango_find_paragraph_boundary ()
void
pango_find_paragraph_boundary (const gchar *text,
gint length,
gint *paragraph_delimiter_index,
gint *next_paragraph_start);
Locates a paragraph boundary in text
. A boundary is caused by
delimiter characters, such as a newline, carriage return, carriage
return-newline pair, or Unicode paragraph separator character. The
index of the run of delimiters is returned in
paragraph_delimiter_index
. The index of the start of the paragraph
(index after all delimiters) is stored in next_paragraph_start
.
If no delimiters are found, both paragraph_delimiter_index
and
next_paragraph_start
are filled with the length of text
(an index one
off the end).
pango_default_break ()
void
pango_default_break (const gchar *text,
int length,
PangoAnalysis *analysis,
PangoLogAttr *attrs,
int attrs_len);
This is the default break algorithm. It applies Unicode
rules without language-specific tailoring, therefore
the analyis
argument is unused and can be NULL.
See pango_tailor_break() for language-specific breaks.
pango_tailor_break ()
void
pango_tailor_break (const char *text,
int length,
PangoAnalysis *analysis,
int offset,
PangoLogAttr *log_attrs,
int log_attrs_len);
Apply language-specific tailoring to the breaks in
log_attrs
, which are assumed to have been produced
by pango_default_break().
If offset
is not -1, it is used to apply attributes
from analysis
that are relevant to line breaking.
Since: 1.44
pango_shape ()
void
pango_shape (const char *text,
int length,
const PangoAnalysis *analysis,
PangoGlyphString *glyphs);
Given a segment of text and the corresponding
PangoAnalysis structure returned from pango_itemize(),
convert the characters into glyphs. You may also pass
in only a substring of the item from pango_itemize().
It is recommended that you use pango_shape_full() instead, since
that API allows for shaping interaction happening across text item
boundaries.
pango_shape_full ()
void
pango_shape_full (const char *item_text,
int item_length,
const char *paragraph_text,
int paragraph_length,
const PangoAnalysis *analysis,
PangoGlyphString *glyphs);
Given a segment of text and the corresponding
PangoAnalysis structure returned from pango_itemize(),
convert the characters into glyphs. You may also pass
in only a substring of the item from pango_itemize().
This is similar to pango_shape(), except it also can optionally take
the full paragraph text as input, which will then be used to perform
certain cross-item shaping interactions. If you have access to the broader
text of which item_text
is part of, provide the broader text as
paragraph_text
. If paragraph_text
is NULL, item text is used instead.
Since: 1.32
pango_shape_with_flags ()
void
pango_shape_with_flags (const char *item_text,
int item_length,
const char *paragraph_text,
int paragraph_length,
const PangoAnalysis *analysis,
PangoGlyphString *glyphs,
PangoShapeFlags flags);
Given a segment of text and the corresponding
PangoAnalysis structure returned from pango_itemize(),
convert the characters into glyphs. You may also pass
in only a substring of the item from pango_itemize().
This is similar to pango_shape_full(), except it also takes
flags that can influence the shaping process.
Since: 1.44
Types and Values
struct PangoItem
struct PangoItem {
gint offset;
gint length;
gint num_chars;
PangoAnalysis analysis;
};
The PangoItem structure stores information about a segment of text.
struct PangoAnalysis
struct PangoAnalysis {
PangoEngineShape *shape_engine;
PangoEngineLang *lang_engine;
PangoFont *font;
guint8 level;
guint8 gravity;
guint8 flags;
guint8 script;
PangoLanguage *language;
GSList *extra_attrs;
};
The PangoAnalysis structure stores information about
the properties of a segment of text.
PANGO_ANALYSIS_FLAG_CENTERED_BASELINE
#define PANGO_ANALYSIS_FLAG_CENTERED_BASELINE (1 << 0)
Whether the segment should be shifted to center around the baseline.
Used in vertical writing directions mostly.
Since: 1.16
PANGO_ANALYSIS_FLAG_IS_ELLIPSIS
#define PANGO_ANALYSIS_FLAG_IS_ELLIPSIS (1 << 1)
This flag is used to mark runs that hold ellipsized text,
in an ellipsized layout.
Since: 1.36.7
PANGO_ANALYSIS_FLAG_NEED_HYPHEN
#define PANGO_ANALYSIS_FLAG_NEED_HYPHEN (1 << 2)
This flag tells Pango to add a hyphen at the end of the
run during shaping.
Since: 1.44
PangoLogAttr
typedef struct {
guint is_line_break : 1;
guint is_mandatory_break : 1;
guint is_char_break : 1;
guint is_white : 1;
guint is_cursor_position : 1;
guint is_word_start : 1;
guint is_word_end : 1;
guint is_sentence_boundary : 1;
guint is_sentence_start : 1;
guint is_sentence_end : 1;
guint backspace_deletes_character : 1;
guint is_expandable_space : 1;
guint is_word_boundary : 1;
} PangoLogAttr;
The PangoLogAttr structure stores information
about the attributes of a single character.