1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Structures for storing information about glyphs
7 <!-- ##### SECTION Long_Description ##### -->
9 pango_shape() produces a string of glyphs which
10 can be measured or drawn to the screen. The following
11 structures are used to store information about
15 <!-- ##### SECTION See_Also ##### -->
20 <!-- ##### SECTION Stability_Level ##### -->
23 <!-- ##### MACRO PANGO_SCALE ##### -->
25 The %PANGO_SCALE macro represents the scale between dimensions used
26 for Pango distances and device units. (The definition of device
27 units is dependent on the output device; it will typically be pixels
28 for a screen, and points for a printer.) %PANGO_SCALE is currently
29 1024, but this may be changed in the future.
32 When setting font sizes, device units are always considered to be
33 points (as in "12 point font"), rather than pixels.
38 <!-- ##### MACRO PANGO_PIXELS ##### -->
40 Converts a dimension to device units by rounding.
43 @d: a dimension in Pango units.
44 @Returns: rounded dimension in device units.
47 <!-- ##### MACRO PANGO_PIXELS_FLOOR ##### -->
49 Converts a dimension to device units by flooring.
52 @d: a dimension in Pango units.
53 @Returns: floored dimension in device units.
57 <!-- ##### MACRO PANGO_PIXELS_CEIL ##### -->
59 Converts a dimension to device units by ceiling.
62 @d: a dimension in Pango units.
63 @Returns: ceiled dimension in device units.
67 <!-- ##### MACRO PANGO_UNITS_ROUND ##### -->
69 Rounds a dimension to whole device units, but does not
70 convert it to device units.
73 @d: a dimension in Pango units.
74 @Returns: rounded dimension in Pango units.
78 <!-- ##### FUNCTION pango_units_to_double ##### -->
87 <!-- ##### FUNCTION pango_units_from_double ##### -->
96 <!-- ##### STRUCT PangoRectangle ##### -->
98 The #PangoRectangle structure represents a rectangle. It is frequently
99 used to represent the logical or ink extents of a single glyph or section
100 of text. (See, for instance, pango_font_get_glyph_extents())
103 @x: X coordinate of the left side of the rectangle.
104 @y: Y coordinate of the the top side of the rectangle.
105 @width: width of the rectangle.
106 @height: height of the rectangle.
108 <!-- ##### MACRO PANGO_ASCENT ##### -->
110 Extracts the <firstterm>ascent</firstterm> from a #PangoRectangle
111 representing glyph extents. The ascent is the distance from the
112 baseline to the highest point of the character. This is positive if the
113 glyph ascends above the baseline.
116 @rect: a #PangoRectangle
119 <!-- ##### MACRO PANGO_DESCENT ##### -->
121 Extracts the <firstterm>descent</firstterm> from a #PangoRectangle
122 representing glyph extents. The descent is the distance from the
123 baseline to the lowest point of the character. This is positive if the
124 glyph descends below the baseline.
127 @rect: a #PangoRectangle
130 <!-- ##### MACRO PANGO_LBEARING ##### -->
132 Extracts the <firstterm>left bearing</firstterm> from a #PangoRectangle
133 representing glyph extents. The left bearing is the distance from the
134 horizontal origin to the farthest left point of the character.
135 This is positive for characters drawn completely to the right of the
139 @rect: a #PangoRectangle
142 <!-- ##### MACRO PANGO_RBEARING ##### -->
144 Extracts the <firstterm>right bearing</firstterm> from a #PangoRectangle
145 representing glyph extents. The right bearing is the distance from the
146 horizontal origin to the farthest right point of the character.
147 This is positive except for characters drawn completely to the left of the
151 @rect: a #PangoRectangle
154 <!-- ##### FUNCTION pango_extents_to_pixels ##### -->
163 <!-- ##### STRUCT PangoMatrix ##### -->
175 <!-- ##### MACRO PANGO_TYPE_MATRIX ##### -->
182 <!-- ##### MACRO PANGO_MATRIX_INIT ##### -->
189 <!-- ##### FUNCTION pango_matrix_copy ##### -->
198 <!-- ##### FUNCTION pango_matrix_free ##### -->
206 <!-- ##### FUNCTION pango_matrix_translate ##### -->
216 <!-- ##### FUNCTION pango_matrix_scale ##### -->
226 <!-- ##### FUNCTION pango_matrix_rotate ##### -->
235 <!-- ##### FUNCTION pango_matrix_concat ##### -->
244 <!-- ##### FUNCTION pango_matrix_transform_point ##### -->
254 <!-- ##### FUNCTION pango_matrix_transform_distance ##### -->
264 <!-- ##### FUNCTION pango_matrix_transform_rectangle ##### -->
273 <!-- ##### FUNCTION pango_matrix_transform_pixel_rectangle ##### -->
282 <!-- ##### FUNCTION pango_matrix_get_font_scale_factor ##### -->
291 <!-- ##### TYPEDEF PangoGlyph ##### -->
293 A #PangoGlyph represents a single glyph in the output form of a string.
297 <!-- ##### MACRO PANGO_GLYPH_EMPTY ##### -->
299 The %PANGO_GLYPH_EMPTY macro represents a #PangoGlyph value that has a
300 special meaning, which is a zero-width empty glyph. This is useful for
301 example in shaper modules, to use as the glyph for various zero-width
302 Unicode characters (those passing pango_is_zero_width()).
307 <!-- ##### MACRO PANGO_GLYPH_INVALID_INPUT ##### -->
309 The %PANGO_GLYPH_EMPTY macro represents a #PangoGlyph value that has a
310 special meaning of invalid input. #PangoLayout produces one such glyph
311 per invalid input UTF-8 byte and such a glyph is rendered as a crossed
314 Note that this value is defined such that it has the %PANGO_GLYPH_UNKNOWN_FLAG
321 <!-- ##### MACRO PANGO_GLYPH_UNKNOWN_FLAG ##### -->
323 The %PANGO_GLYPH_UNKNOWN_FLAG macro is a flag value that can be added to
324 a #gunichar value of a valid Unicode character, to produce a #PangoGlyph
325 value, representing an unknown-character glyph for the respective #gunichar.
330 <!-- ##### MACRO PANGO_GET_UNKNOWN_GLYPH ##### -->
332 Returns a #PangoGlyph value that means no glyph was found for @wc.
333 The way this unknown glyphs are rendered is backend specific. For example,
334 a box with the hexadecimal Unicode code-point of the character written in it
335 is what is done in the most common backends.
338 @wc: a Unicode character
341 <!-- ##### STRUCT PangoGlyphInfo ##### -->
343 The #PangoGlyphInfo structure represents a single glyph together with
344 positioning information and visual attributes.
345 It contains the following fields.
348 @glyph: the glyph itself.
349 @geometry: the positional information about the glyph.
350 @attr: the visual attributes of the glyph.
352 <!-- ##### STRUCT PangoGlyphGeometry ##### -->
354 The #PangoGlyphGeometry structure contains width and positioning
355 information for a single glyph.
358 @width: the logical width to use for the the character.
359 @x_offset: horizontal offset from nominal character position.
360 @y_offset: vertical offset from nominal character position.
362 <!-- ##### TYPEDEF PangoGlyphUnit ##### -->
364 The #PangoGlyphUnit type is used to store dimensions within
365 Pango. Dimensions are stored in 1/%PANGO_SCALE of a device unit.
366 (A device unit might be a pixel for screen display, or
367 a point on a printer.) %PANGO_SCALE is currently 1024, and
368 may change in the future (unlikely though), but you should not
369 depend on its exact value. The PANGO_PIXELS() macro can be used
370 to convert from glyph units into device units with correct rounding.
374 <!-- ##### STRUCT PangoGlyphVisAttr ##### -->
376 The PangoGlyphVisAttr is used to communicate information between
377 the shaping phase and the rendering phase. More attributes may be
381 @is_cluster_start: set for the first logical glyph in each cluster. (Clusters
382 are stored in visual order, within the cluster, glyphs
383 are always ordered in logical order, since visual
384 order is meaningless; that is, in Arabic text, accent glyphs
385 follow the glyphs for the base character.)
387 <!-- ##### STRUCT PangoGlyphString ##### -->
389 The #PangoGlyphString structure is used to store strings
390 of glyphs with geometry and visual attribute information.
391 The storage for the glyph information is owned
392 by the structure which simplifies memory management.
395 @num_glyphs: the number of glyphs in the string.
396 @glyphs: an array of #PangoGlyphInfo structures of length <structfield>num_glyphs</structfield>.
397 @log_clusters: for each glyph, byte index of the starting character for the
398 cluster. The indices are relative to the start of the text
399 corresponding to the PangoGlyphString.
401 <!-- ##### STRUCT PangoGlyphItem ##### -->
403 A #PangoGlyphItem is a pair of a #PangoItem and the glyphs
404 resulting from shaping the text corresponding to an item.
405 As an example of the usage of #PangoGlyphItem, the results
406 of shaping text with #PangoLayout is a list of #PangoLayoutLine,
407 each of which contains a list of #PangoGlyphItem.
410 @item: a #PangoItem structure that provides information
411 about a segment of text.
412 @glyphs: the glyphs obtained by shaping the text
413 corresponding to @item.
415 <!-- ##### STRUCT PangoGlyphItemIter ##### -->
417 A #PangoGlyphItemIter is an iterator over the clusters in a
418 #PangoGlyphItem. The <firstterm>forward direction</firstterm> of the
419 iterator is the logical direction of text. That is, with increasing
420 @start_index and @start_char values. If @glyph_item is right-to-left
421 (that is, if <literal>@glyph_item->item->analysis.level</literal> is odd),
422 then @start_glyph decreases as the iterator moves forward. Moreover,
423 in right-to-left cases, @start_glyph is greater than @end_glyph.
425 An iterator should be initialized using either of
426 pango_glyph_item_iter_init_start() and
427 pango_glyph_item_iter_init_end(), for forward and backward iteration
428 respectively, and walked over using any desired mixture of
429 pango_glyph_item_iter_next_cluster() and
430 pango_glyph_item_iter_prev_cluster(). A common idiom for doing a
431 forward iteration over the clusters is:
433 PangoGlyphItemIter cluster_iter;
434 gboolean have_cluster;
436 for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
439 have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
445 Note that @text is the start of the text for layout, which is then
446 indexed by <literal>@glyph_item->item->offset</literal> to get to the
447 text of @glyph_item. The @start_index and @end_index values can directly
448 index into @text. The @start_glyph, @end_glyph, @start_char, and @end_char
449 values however are zero-based for the @glyph_item. For each cluster, the
450 item pointed at by the start variables is included in the cluster while
451 the one pointed at by end variables is not.
453 None of the members of a #PangoGlyphItemIter should be modified manually.
457 @glyph_item: the #PangoGlyphItem this iterator iterates over
458 @text: the UTF-8 text that @glyph_item refers to
459 @start_glyph: starting glyph of the cluster
460 @start_index: starting text index of the cluster
461 @start_char: starting number of characters of the cluster
462 @end_glyph: ending glyph of the cluster
463 @end_index: ending text index of the cluster
464 @end_char: ending number of characters of the cluster
467 <!-- ##### MACRO PANGO_TYPE_GLYPH_STRING ##### -->
469 The #GObject type for #PangoGlyphString.
474 <!-- ##### FUNCTION pango_glyph_string_new ##### -->
482 <!-- ##### FUNCTION pango_glyph_string_copy ##### -->
491 <!-- ##### FUNCTION pango_glyph_string_set_size ##### -->
500 <!-- ##### FUNCTION pango_glyph_string_free ##### -->
508 <!-- ##### FUNCTION pango_glyph_string_extents ##### -->
519 <!-- ##### FUNCTION pango_glyph_string_extents_range ##### -->
532 <!-- ##### FUNCTION pango_glyph_string_get_width ##### -->
541 <!-- ##### FUNCTION pango_glyph_string_index_to_x ##### -->
555 <!-- ##### FUNCTION pango_glyph_string_x_to_index ##### -->
569 <!-- ##### FUNCTION pango_glyph_string_get_logical_widths ##### -->
581 <!-- ##### MACRO PANGO_TYPE_GLYPH_ITEM ##### -->
583 The #GObject type for #PangoGlyphItem.
589 <!-- ##### FUNCTION pango_glyph_item_copy ##### -->
598 <!-- ##### FUNCTION pango_glyph_item_free ##### -->
606 <!-- ##### FUNCTION pango_glyph_item_split ##### -->
617 <!-- ##### FUNCTION pango_glyph_item_apply_attrs ##### -->
628 <!-- ##### FUNCTION pango_glyph_item_letter_space ##### -->
639 <!-- ##### FUNCTION pango_glyph_item_get_logical_widths ##### -->
649 <!-- ##### MACRO PANGO_TYPE_GLYPH_ITEM_ITER ##### -->
651 The #GObject type for #PangoGlyphItemIter.
657 <!-- ##### FUNCTION pango_glyph_item_iter_copy ##### -->
666 <!-- ##### FUNCTION pango_glyph_item_iter_free ##### -->
674 <!-- ##### FUNCTION pango_glyph_item_iter_init_start ##### -->
685 <!-- ##### FUNCTION pango_glyph_item_iter_init_end ##### -->
696 <!-- ##### FUNCTION pango_glyph_item_iter_next_cluster ##### -->
705 <!-- ##### FUNCTION pango_glyph_item_iter_prev_cluster ##### -->