pango-glyph.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* Pango
  2. * pango-glyph.h: Glyph storage
  3. *
  4. * Copyright (C) 2000 Red Hat Software
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __PANGO_GLYPH_H__
  22. #define __PANGO_GLYPH_H__
  23. #include <pango/pango-types.h>
  24. #include <pango/pango-item.h>
  25. G_BEGIN_DECLS
  26. typedef struct _PangoGlyphGeometry PangoGlyphGeometry;
  27. typedef struct _PangoGlyphVisAttr PangoGlyphVisAttr;
  28. typedef struct _PangoGlyphInfo PangoGlyphInfo;
  29. typedef struct _PangoGlyphString PangoGlyphString;
  30. /* 1024ths of a device unit */
  31. /**
  32. * PangoGlyphUnit:
  33. *
  34. * The #PangoGlyphUnit type is used to store dimensions within
  35. * Pango. Dimensions are stored in 1/%PANGO_SCALE of a device unit.
  36. * (A device unit might be a pixel for screen display, or
  37. * a point on a printer.) %PANGO_SCALE is currently 1024, and
  38. * may change in the future (unlikely though), but you should not
  39. * depend on its exact value. The PANGO_PIXELS() macro can be used
  40. * to convert from glyph units into device units with correct rounding.
  41. */
  42. typedef gint32 PangoGlyphUnit;
  43. /* Positioning information about a glyph
  44. */
  45. /**
  46. * PangoGlyphGeometry:
  47. * @width: the logical width to use for the the character.
  48. * @x_offset: horizontal offset from nominal character position.
  49. * @y_offset: vertical offset from nominal character position.
  50. *
  51. * The #PangoGlyphGeometry structure contains width and positioning
  52. * information for a single glyph.
  53. */
  54. struct _PangoGlyphGeometry
  55. {
  56. PangoGlyphUnit width;
  57. PangoGlyphUnit x_offset;
  58. PangoGlyphUnit y_offset;
  59. };
  60. /* Visual attributes of a glyph
  61. */
  62. /**
  63. * PangoGlyphVisAttr:
  64. * @is_cluster_start: set for the first logical glyph in each cluster. (Clusters
  65. * are stored in visual order, within the cluster, glyphs
  66. * are always ordered in logical order, since visual
  67. * order is meaningless; that is, in Arabic text, accent glyphs
  68. * follow the glyphs for the base character.)
  69. *
  70. * The PangoGlyphVisAttr is used to communicate information between
  71. * the shaping phase and the rendering phase. More attributes may be
  72. * added in the future.
  73. */
  74. struct _PangoGlyphVisAttr
  75. {
  76. guint is_cluster_start : 1;
  77. };
  78. /* A single glyph
  79. */
  80. /**
  81. * PangoGlyphInfo:
  82. * @glyph: the glyph itself.
  83. * @geometry: the positional information about the glyph.
  84. * @attr: the visual attributes of the glyph.
  85. *
  86. * The #PangoGlyphInfo structure represents a single glyph together with
  87. * positioning information and visual attributes.
  88. * It contains the following fields.
  89. */
  90. struct _PangoGlyphInfo
  91. {
  92. PangoGlyph glyph;
  93. PangoGlyphGeometry geometry;
  94. PangoGlyphVisAttr attr;
  95. };
  96. /* A string of glyphs with positional information and visual attributes -
  97. * ready for drawing
  98. */
  99. /**
  100. * PangoGlyphString:
  101. * @num_glyphs: number of the glyphs in this glyph string.
  102. * @glyphs: (array length=num_glyphs): array of glyph information
  103. * for the glyph string.
  104. * @log_clusters: logical cluster info, indexed by the byte index
  105. * within the text corresponding to the glyph string.
  106. *
  107. * The #PangoGlyphString structure is used to store strings
  108. * of glyphs with geometry and visual attribute information.
  109. * The storage for the glyph information is owned
  110. * by the structure which simplifies memory management.
  111. */
  112. struct _PangoGlyphString {
  113. gint num_glyphs;
  114. PangoGlyphInfo *glyphs;
  115. /* This is a memory inefficient way of representing the information
  116. * here - each value gives the byte index within the text
  117. * corresponding to the glyph string of the start of the cluster to
  118. * which the glyph belongs.
  119. */
  120. gint *log_clusters;
  121. /*< private >*/
  122. gint space;
  123. };
  124. /**
  125. * PANGO_TYPE_GLYPH_STRING:
  126. *
  127. * The #GObject type for #PangoGlyphString.
  128. */
  129. #define PANGO_TYPE_GLYPH_STRING (pango_glyph_string_get_type ())
  130. PangoGlyphString *pango_glyph_string_new (void);
  131. void pango_glyph_string_set_size (PangoGlyphString *string,
  132. gint new_len);
  133. GType pango_glyph_string_get_type (void) G_GNUC_CONST;
  134. PangoGlyphString *pango_glyph_string_copy (PangoGlyphString *string);
  135. void pango_glyph_string_free (PangoGlyphString *string);
  136. void pango_glyph_string_extents (PangoGlyphString *glyphs,
  137. PangoFont *font,
  138. PangoRectangle *ink_rect,
  139. PangoRectangle *logical_rect);
  140. int pango_glyph_string_get_width(PangoGlyphString *glyphs);
  141. void pango_glyph_string_extents_range (PangoGlyphString *glyphs,
  142. int start,
  143. int end,
  144. PangoFont *font,
  145. PangoRectangle *ink_rect,
  146. PangoRectangle *logical_rect);
  147. void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
  148. const char *text,
  149. int length,
  150. int embedding_level,
  151. int *logical_widths);
  152. void pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
  153. char *text,
  154. int length,
  155. PangoAnalysis *analysis,
  156. int index_,
  157. gboolean trailing,
  158. int *x_pos);
  159. void pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
  160. char *text,
  161. int length,
  162. PangoAnalysis *analysis,
  163. int x_pos,
  164. int *index_,
  165. int *trailing);
  166. /* Turn a string of characters into a string of glyphs
  167. */
  168. void pango_shape (const gchar *text,
  169. gint length,
  170. const PangoAnalysis *analysis,
  171. PangoGlyphString *glyphs);
  172. void pango_shape_full (const gchar *item_text,
  173. gint item_length,
  174. const gchar *paragraph_text,
  175. gint paragraph_length,
  176. const PangoAnalysis *analysis,
  177. PangoGlyphString *glyphs);
  178. GList *pango_reorder_items (GList *logical_items);
  179. G_END_DECLS
  180. #endif /* __PANGO_GLYPH_H__ */