pango-item.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* Pango
  2. * pango-item.h: Structure for storing run information
  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_ITEM_H__
  22. #define __PANGO_ITEM_H__
  23. #include <pango/pango-types.h>
  24. #include <pango/pango-attributes.h>
  25. G_BEGIN_DECLS
  26. typedef struct _PangoAnalysis PangoAnalysis;
  27. typedef struct _PangoItem PangoItem;
  28. /**
  29. * PANGO_ANALYSIS_FLAG_CENTERED_BASELINE:
  30. *
  31. * Whether the segment should be shifted to center around the baseline.
  32. *
  33. * This is mainly used in vertical writing directions.
  34. *
  35. * Since: 1.16
  36. */
  37. #define PANGO_ANALYSIS_FLAG_CENTERED_BASELINE (1 << 0)
  38. /**
  39. * PANGO_ANALYSIS_FLAG_IS_ELLIPSIS:
  40. *
  41. * Whether this run holds ellipsized text.
  42. *
  43. * Since: 1.36.7
  44. */
  45. #define PANGO_ANALYSIS_FLAG_IS_ELLIPSIS (1 << 1)
  46. /**
  47. * PANGO_ANALYSIS_FLAG_NEED_HYPHEN:
  48. *
  49. * Whether to add a hyphen at the end of the run during shaping.
  50. *
  51. * Since: 1.44
  52. */
  53. #define PANGO_ANALYSIS_FLAG_NEED_HYPHEN (1 << 2)
  54. /**
  55. * PangoAnalysis:
  56. * @shape_engine: unused, reserved
  57. * @lang_engine: unused, reserved
  58. * @font: the font for this segment.
  59. * @level: the bidirectional level for this segment.
  60. * @gravity: the glyph orientation for this segment (A `PangoGravity`).
  61. * @flags: boolean flags for this segment (Since: 1.16).
  62. * @script: the detected script for this segment (A `PangoScript`) (Since: 1.18).
  63. * @language: the detected language for this segment.
  64. * @extra_attrs: extra attributes for this segment.
  65. *
  66. * The `PangoAnalysis` structure stores information about
  67. * the properties of a segment of text.
  68. */
  69. struct _PangoAnalysis
  70. {
  71. #ifndef __GI_SCANNER__
  72. PangoEngineShape *shape_engine;
  73. PangoEngineLang *lang_engine;
  74. #else
  75. gpointer shape_engine;
  76. gpointer lang_engine;
  77. #endif
  78. PangoFont *font;
  79. guint8 level;
  80. guint8 gravity;
  81. guint8 flags;
  82. guint8 script;
  83. PangoLanguage *language;
  84. GSList *extra_attrs;
  85. };
  86. /**
  87. * PangoItem:
  88. * @offset: byte offset of the start of this item in text.
  89. * @length: length of this item in bytes.
  90. * @num_chars: number of Unicode characters in the item.
  91. * @analysis: analysis results for the item.
  92. *
  93. * The `PangoItem` structure stores information about a segment of text.
  94. *
  95. * You typically obtain `PangoItems` by itemizing a piece of text
  96. * with [func@itemize].
  97. */
  98. struct _PangoItem
  99. {
  100. int offset;
  101. int length;
  102. int num_chars;
  103. PangoAnalysis analysis;
  104. };
  105. #define PANGO_TYPE_ITEM (pango_item_get_type ())
  106. PANGO_AVAILABLE_IN_ALL
  107. GType pango_item_get_type (void) G_GNUC_CONST;
  108. PANGO_AVAILABLE_IN_ALL
  109. PangoItem * pango_item_new (void);
  110. PANGO_AVAILABLE_IN_ALL
  111. PangoItem * pango_item_copy (PangoItem *item);
  112. PANGO_AVAILABLE_IN_ALL
  113. void pango_item_free (PangoItem *item);
  114. PANGO_AVAILABLE_IN_1_54
  115. int pango_item_get_char_offset (PangoItem *item);
  116. PANGO_AVAILABLE_IN_ALL
  117. PangoItem * pango_item_split (PangoItem *orig,
  118. int split_index,
  119. int split_offset);
  120. PANGO_AVAILABLE_IN_1_44
  121. void pango_item_apply_attrs (PangoItem *item,
  122. PangoAttrIterator *iter);
  123. PANGO_AVAILABLE_IN_ALL
  124. GList * pango_reorder_items (GList *items);
  125. /* Itemization */
  126. PANGO_AVAILABLE_IN_ALL
  127. GList * pango_itemize (PangoContext *context,
  128. const char *text,
  129. int start_index,
  130. int length,
  131. PangoAttrList *attrs,
  132. PangoAttrIterator *cached_iter);
  133. PANGO_AVAILABLE_IN_1_4
  134. GList * pango_itemize_with_base_dir (PangoContext *context,
  135. PangoDirection base_dir,
  136. const char *text,
  137. int start_index,
  138. int length,
  139. PangoAttrList *attrs,
  140. PangoAttrIterator *cached_iter);
  141. G_END_DECLS
  142. #endif /* __PANGO_ITEM_H__ */