pango-attributes.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /* Pango
  2. * pango-attributes.h: Attributed text
  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_ATTRIBUTES_H__
  22. #define __PANGO_ATTRIBUTES_H__
  23. #include <pango/pango-font.h>
  24. #include <pango/pango-color.h>
  25. #include <glib-object.h>
  26. G_BEGIN_DECLS
  27. typedef struct _PangoAttribute PangoAttribute;
  28. typedef struct _PangoAttrClass PangoAttrClass;
  29. typedef struct _PangoAttrString PangoAttrString;
  30. typedef struct _PangoAttrLanguage PangoAttrLanguage;
  31. typedef struct _PangoAttrInt PangoAttrInt;
  32. typedef struct _PangoAttrSize PangoAttrSize;
  33. typedef struct _PangoAttrFloat PangoAttrFloat;
  34. typedef struct _PangoAttrColor PangoAttrColor;
  35. typedef struct _PangoAttrFontDesc PangoAttrFontDesc;
  36. typedef struct _PangoAttrShape PangoAttrShape;
  37. typedef struct _PangoAttrFontFeatures PangoAttrFontFeatures;
  38. /**
  39. * PangoAttrType:
  40. * @PANGO_ATTR_INVALID: does not happen
  41. * @PANGO_ATTR_LANGUAGE: language ([struct@Pango.AttrLanguage])
  42. * @PANGO_ATTR_FAMILY: font family name list ([struct@Pango.AttrString])
  43. * @PANGO_ATTR_STYLE: font slant style ([struct@Pango.AttrInt])
  44. * @PANGO_ATTR_WEIGHT: font weight ([struct@Pango.AttrInt])
  45. * @PANGO_ATTR_VARIANT: font variant (normal or small caps) ([struct@Pango.AttrInt])
  46. * @PANGO_ATTR_STRETCH: font stretch ([struct@Pango.AttrInt])
  47. * @PANGO_ATTR_SIZE: font size in points scaled by %PANGO_SCALE ([struct@Pango.AttrInt])
  48. * @PANGO_ATTR_FONT_DESC: font description ([struct@Pango.AttrFontDesc])
  49. * @PANGO_ATTR_FOREGROUND: foreground color ([struct@Pango.AttrColor])
  50. * @PANGO_ATTR_BACKGROUND: background color ([struct@Pango.AttrColor])
  51. * @PANGO_ATTR_UNDERLINE: whether the text has an underline ([struct@Pango.AttrInt])
  52. * @PANGO_ATTR_STRIKETHROUGH: whether the text is struck-through ([struct@Pango.AttrInt])
  53. * @PANGO_ATTR_RISE: baseline displacement ([struct@Pango.AttrInt])
  54. * @PANGO_ATTR_SHAPE: shape ([struct@Pango.AttrShape])
  55. * @PANGO_ATTR_SCALE: font size scale factor ([struct@Pango.AttrFloat])
  56. * @PANGO_ATTR_FALLBACK: whether fallback is enabled ([struct@Pango.AttrInt])
  57. * @PANGO_ATTR_LETTER_SPACING: letter spacing ([struct@PangoAttrInt])
  58. * @PANGO_ATTR_UNDERLINE_COLOR: underline color ([struct@Pango.AttrColor])
  59. * @PANGO_ATTR_STRIKETHROUGH_COLOR: strikethrough color ([struct@Pango.AttrColor])
  60. * @PANGO_ATTR_ABSOLUTE_SIZE: font size in pixels scaled by %PANGO_SCALE ([struct@Pango.AttrInt])
  61. * @PANGO_ATTR_GRAVITY: base text gravity ([struct@Pango.AttrInt])
  62. * @PANGO_ATTR_GRAVITY_HINT: gravity hint ([struct@Pango.AttrInt])
  63. * @PANGO_ATTR_FONT_FEATURES: OpenType font features ([struct@Pango.AttrFontFeatures]). Since 1.38
  64. * @PANGO_ATTR_FOREGROUND_ALPHA: foreground alpha ([struct@Pango.AttrInt]). Since 1.38
  65. * @PANGO_ATTR_BACKGROUND_ALPHA: background alpha ([struct@Pango.AttrInt]). Since 1.38
  66. * @PANGO_ATTR_ALLOW_BREAKS: whether breaks are allowed ([struct@Pango.AttrInt]). Since 1.44
  67. * @PANGO_ATTR_SHOW: how to render invisible characters ([struct@Pango.AttrInt]). Since 1.44
  68. * @PANGO_ATTR_INSERT_HYPHENS: whether to insert hyphens at intra-word line breaks ([struct@Pango.AttrInt]). Since 1.44
  69. * @PANGO_ATTR_OVERLINE: whether the text has an overline ([struct@Pango.AttrInt]). Since 1.46
  70. * @PANGO_ATTR_OVERLINE_COLOR: overline color ([struct@Pango.AttrColor]). Since 1.46
  71. * @PANGO_ATTR_LINE_HEIGHT: line height factor ([struct@Pango.AttrFloat]). Since: 1.50
  72. * @PANGO_ATTR_ABSOLUTE_LINE_HEIGHT: line height ([struct@Pango.AttrInt]). Since: 1.50
  73. * @PANGO_ATTR_WORD: override segmentation to classify the range of the attribute as a single word ([struct@Pango.AttrInt]). Since 1.50
  74. * @PANGO_ATTR_SENTENCE: override segmentation to classify the range of the attribute as a single sentence ([struct@Pango.AttrInt]). Since 1.50
  75. * @PANGO_ATTR_BASELINE_SHIFT: baseline displacement ([struct@Pango.AttrInt]). Since 1.50
  76. * @PANGO_ATTR_FONT_SCALE: font-relative size change ([struct@Pango.AttrInt]). Since 1.50
  77. *
  78. * The `PangoAttrType` distinguishes between different types of attributes.
  79. *
  80. * Along with the predefined values, it is possible to allocate additional
  81. * values for custom attributes using [func@AttrType.register]. The predefined
  82. * values are given below. The type of structure used to store the attribute is
  83. * listed in parentheses after the description.
  84. */
  85. typedef enum
  86. {
  87. PANGO_ATTR_INVALID, /* 0 is an invalid attribute type */
  88. PANGO_ATTR_LANGUAGE, /* PangoAttrLanguage */
  89. PANGO_ATTR_FAMILY, /* PangoAttrString */
  90. PANGO_ATTR_STYLE, /* PangoAttrInt */
  91. PANGO_ATTR_WEIGHT, /* PangoAttrInt */
  92. PANGO_ATTR_VARIANT, /* PangoAttrInt */
  93. PANGO_ATTR_STRETCH, /* PangoAttrInt */
  94. PANGO_ATTR_SIZE, /* PangoAttrSize */
  95. PANGO_ATTR_FONT_DESC, /* PangoAttrFontDesc */
  96. PANGO_ATTR_FOREGROUND, /* PangoAttrColor */
  97. PANGO_ATTR_BACKGROUND, /* PangoAttrColor */
  98. PANGO_ATTR_UNDERLINE, /* PangoAttrInt */
  99. PANGO_ATTR_STRIKETHROUGH, /* PangoAttrInt */
  100. PANGO_ATTR_RISE, /* PangoAttrInt */
  101. PANGO_ATTR_SHAPE, /* PangoAttrShape */
  102. PANGO_ATTR_SCALE, /* PangoAttrFloat */
  103. PANGO_ATTR_FALLBACK, /* PangoAttrInt */
  104. PANGO_ATTR_LETTER_SPACING, /* PangoAttrInt */
  105. PANGO_ATTR_UNDERLINE_COLOR, /* PangoAttrColor */
  106. PANGO_ATTR_STRIKETHROUGH_COLOR,/* PangoAttrColor */
  107. PANGO_ATTR_ABSOLUTE_SIZE, /* PangoAttrSize */
  108. PANGO_ATTR_GRAVITY, /* PangoAttrInt */
  109. PANGO_ATTR_GRAVITY_HINT, /* PangoAttrInt */
  110. PANGO_ATTR_FONT_FEATURES, /* PangoAttrFontFeatures */
  111. PANGO_ATTR_FOREGROUND_ALPHA, /* PangoAttrInt */
  112. PANGO_ATTR_BACKGROUND_ALPHA, /* PangoAttrInt */
  113. PANGO_ATTR_ALLOW_BREAKS, /* PangoAttrInt */
  114. PANGO_ATTR_SHOW, /* PangoAttrInt */
  115. PANGO_ATTR_INSERT_HYPHENS, /* PangoAttrInt */
  116. PANGO_ATTR_OVERLINE, /* PangoAttrInt */
  117. PANGO_ATTR_OVERLINE_COLOR, /* PangoAttrColor */
  118. PANGO_ATTR_LINE_HEIGHT, /* PangoAttrFloat */
  119. PANGO_ATTR_ABSOLUTE_LINE_HEIGHT, /* PangoAttrInt */
  120. PANGO_ATTR_TEXT_TRANSFORM, /* PangoAttrInt */
  121. PANGO_ATTR_WORD, /* PangoAttrInt */
  122. PANGO_ATTR_SENTENCE, /* PangoAttrInt */
  123. PANGO_ATTR_BASELINE_SHIFT, /* PangoAttrSize */
  124. PANGO_ATTR_FONT_SCALE, /* PangoAttrInt */
  125. } PangoAttrType;
  126. /**
  127. * PangoUnderline:
  128. * @PANGO_UNDERLINE_NONE: no underline should be drawn
  129. * @PANGO_UNDERLINE_SINGLE: a single underline should be drawn
  130. * @PANGO_UNDERLINE_DOUBLE: a double underline should be drawn
  131. * @PANGO_UNDERLINE_LOW: a single underline should be drawn at a
  132. * position beneath the ink extents of the text being
  133. * underlined. This should be used only for underlining
  134. * single characters, such as for keyboard accelerators.
  135. * %PANGO_UNDERLINE_SINGLE should be used for extended
  136. * portions of text.
  137. * @PANGO_UNDERLINE_ERROR: an underline indicating an error should
  138. * be drawn below. The exact style of rendering is up to the
  139. * `PangoRenderer` in use, but typical styles include wavy
  140. * or dotted lines.
  141. * This underline is typically used to indicate an error such
  142. * as a possible mispelling; in some cases a contrasting color
  143. * may automatically be used. This type of underlining is
  144. * available since Pango 1.4.
  145. * @PANGO_UNDERLINE_SINGLE_LINE: Like @PANGO_UNDERLINE_SINGLE, but
  146. * drawn continuously across multiple runs. This type
  147. * of underlining is available since Pango 1.46.
  148. * @PANGO_UNDERLINE_DOUBLE_LINE: Like @PANGO_UNDERLINE_DOUBLE, but
  149. * drawn continuously across multiple runs. This type
  150. * of underlining is available since Pango 1.46.
  151. * @PANGO_UNDERLINE_ERROR_LINE: Like @PANGO_UNDERLINE_ERROR, but
  152. * drawn continuously across multiple runs. This type
  153. * of underlining is available since Pango 1.46.
  154. *
  155. * The `PangoUnderline` enumeration is used to specify whether text
  156. * should be underlined, and if so, the type of underlining.
  157. */
  158. typedef enum {
  159. PANGO_UNDERLINE_NONE,
  160. PANGO_UNDERLINE_SINGLE,
  161. PANGO_UNDERLINE_DOUBLE,
  162. PANGO_UNDERLINE_LOW,
  163. PANGO_UNDERLINE_ERROR,
  164. PANGO_UNDERLINE_SINGLE_LINE,
  165. PANGO_UNDERLINE_DOUBLE_LINE,
  166. PANGO_UNDERLINE_ERROR_LINE
  167. } PangoUnderline;
  168. /**
  169. * PangoOverline:
  170. * @PANGO_OVERLINE_NONE: no overline should be drawn
  171. * @PANGO_OVERLINE_SINGLE: Draw a single line above the ink
  172. * extents of the text being underlined.
  173. *
  174. * The `PangoOverline` enumeration is used to specify whether text
  175. * should be overlined, and if so, the type of line.
  176. *
  177. * Since: 1.46
  178. */
  179. typedef enum {
  180. PANGO_OVERLINE_NONE,
  181. PANGO_OVERLINE_SINGLE
  182. } PangoOverline;
  183. /**
  184. * PangoShowFlags:
  185. * @PANGO_SHOW_NONE: No special treatment for invisible characters
  186. * @PANGO_SHOW_SPACES: Render spaces, tabs and newlines visibly
  187. * @PANGO_SHOW_LINE_BREAKS: Render line breaks visibly
  188. * @PANGO_SHOW_IGNORABLES: Render default-ignorable Unicode
  189. * characters visibly
  190. *
  191. * These flags affect how Pango treats characters that are normally
  192. * not visible in the output.
  193. *
  194. * Since: 1.44
  195. */
  196. typedef enum {
  197. PANGO_SHOW_NONE = 0,
  198. PANGO_SHOW_SPACES = 1 << 0,
  199. PANGO_SHOW_LINE_BREAKS = 1 << 1,
  200. PANGO_SHOW_IGNORABLES = 1 << 2
  201. } PangoShowFlags;
  202. /**
  203. * PangoTextTransform:
  204. * @PANGO_TEXT_TRANSFORM_NONE: Leave text unchanged
  205. * @PANGO_TEXT_TRANSFORM_LOWERCASE: Display letters and numbers as lowercase
  206. * @PANGO_TEXT_TRANSFORM_UPPERCASE: Display letters and numbers as uppercase
  207. * @PANGO_TEXT_TRANSFORM_CAPITALIZE: Display the first character of a word
  208. * in titlecase
  209. *
  210. * An enumeration that affects how Pango treats characters during shaping.
  211. *
  212. * Since: 1.50
  213. */
  214. typedef enum {
  215. PANGO_TEXT_TRANSFORM_NONE,
  216. PANGO_TEXT_TRANSFORM_LOWERCASE,
  217. PANGO_TEXT_TRANSFORM_UPPERCASE,
  218. PANGO_TEXT_TRANSFORM_CAPITALIZE,
  219. } PangoTextTransform;
  220. /**
  221. * PangoBaselineShift:
  222. * @PANGO_BASELINE_SHIFT_NONE: Leave the baseline unchanged
  223. * @PANGO_BASELINE_SHIFT_SUPERSCRIPT: Shift the baseline to the superscript position,
  224. * relative to the previous run
  225. * @PANGO_BASELINE_SHIFT_SUBSCRIPT: Shift the baseline to the subscript position,
  226. * relative to the previous run
  227. *
  228. * An enumeration that affects baseline shifts between runs.
  229. *
  230. * Since: 1.50
  231. */
  232. typedef enum {
  233. PANGO_BASELINE_SHIFT_NONE,
  234. PANGO_BASELINE_SHIFT_SUPERSCRIPT,
  235. PANGO_BASELINE_SHIFT_SUBSCRIPT,
  236. } PangoBaselineShift;
  237. /**
  238. * PangoFontScale:
  239. * @PANGO_FONT_SCALE_NONE: Leave the font size unchanged
  240. * @PANGO_FONT_SCALE_SUPERSCRIPT: Change the font to a size suitable for superscripts
  241. * @PANGO_FONT_SCALE_SUBSCRIPT: Change the font to a size suitable for subscripts
  242. * @PANGO_FONT_SCALE_SMALL_CAPS: Change the font to a size suitable for Small Caps
  243. *
  244. * An enumeration that affects font sizes for superscript
  245. * and subscript positioning and for (emulated) Small Caps.
  246. *
  247. * Since: 1.50
  248. */
  249. typedef enum {
  250. PANGO_FONT_SCALE_NONE,
  251. PANGO_FONT_SCALE_SUPERSCRIPT,
  252. PANGO_FONT_SCALE_SUBSCRIPT,
  253. PANGO_FONT_SCALE_SMALL_CAPS,
  254. } PangoFontScale;
  255. /**
  256. * PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING:
  257. *
  258. * Value for @start_index in `PangoAttribute` that indicates
  259. * the beginning of the text.
  260. *
  261. * Since: 1.24
  262. */
  263. #define PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING ((guint)0)
  264. /**
  265. * PANGO_ATTR_INDEX_TO_TEXT_END: (value 4294967295)
  266. *
  267. * Value for @end_index in `PangoAttribute` that indicates
  268. * the end of the text.
  269. *
  270. * Since: 1.24
  271. */
  272. #define PANGO_ATTR_INDEX_TO_TEXT_END ((guint)(G_MAXUINT + 0))
  273. /**
  274. * PangoAttribute:
  275. * @klass: the class structure holding information about the type of the attribute
  276. * @start_index: the start index of the range (in bytes).
  277. * @end_index: end index of the range (in bytes). The character at this index
  278. * is not included in the range.
  279. *
  280. * The `PangoAttribute` structure represents the common portions of all
  281. * attributes.
  282. *
  283. * Particular types of attributes include this structure as their initial
  284. * portion. The common portion of the attribute holds the range to which
  285. * the value in the type-specific part of the attribute applies and should
  286. * be initialized using [method@Pango.Attribute.init]. By default, an attribute
  287. * will have an all-inclusive range of [0,%G_MAXUINT].
  288. */
  289. struct _PangoAttribute
  290. {
  291. const PangoAttrClass *klass;
  292. guint start_index;
  293. guint end_index;
  294. };
  295. /**
  296. * PangoAttrFilterFunc:
  297. * @attribute: a Pango attribute
  298. * @user_data: user data passed to the function
  299. *
  300. * Type of a function filtering a list of attributes.
  301. *
  302. * Return value: %TRUE if the attribute should be selected for
  303. * filtering, %FALSE otherwise.
  304. */
  305. typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute,
  306. gpointer user_data);
  307. /**
  308. * PangoAttrDataCopyFunc:
  309. * @user_data: user data to copy
  310. *
  311. * Type of a function that can duplicate user data for an attribute.
  312. *
  313. * Return value: new copy of @user_data.
  314. **/
  315. typedef gpointer (*PangoAttrDataCopyFunc) (gconstpointer user_data);
  316. /**
  317. * PangoAttrClass:
  318. * @type: the type ID for this attribute
  319. * @copy: function to duplicate an attribute of this type
  320. * (see [method@Pango.Attribute.copy])
  321. * @destroy: function to free an attribute of this type
  322. * (see [method@Pango.Attribute.destroy])
  323. * @equal: function to check two attributes of this type for equality
  324. * (see [method@Pango.Attribute.equal])
  325. *
  326. * The `PangoAttrClass` structure stores the type and operations for
  327. * a particular type of attribute.
  328. *
  329. * The functions in this structure should not be called directly. Instead,
  330. * one should use the wrapper functions provided for `PangoAttribute`.
  331. */
  332. struct _PangoAttrClass
  333. {
  334. /*< public >*/
  335. PangoAttrType type;
  336. PangoAttribute * (*copy) (const PangoAttribute *attr);
  337. void (*destroy) (PangoAttribute *attr);
  338. gboolean (*equal) (const PangoAttribute *attr1, const PangoAttribute *attr2);
  339. };
  340. /**
  341. * PangoAttrString:
  342. * @attr: the common portion of the attribute
  343. * @value: the string which is the value of the attribute
  344. *
  345. * The `PangoAttrString` structure is used to represent attributes with
  346. * a string value.
  347. */
  348. struct _PangoAttrString
  349. {
  350. PangoAttribute attr;
  351. char *value;
  352. };
  353. /**
  354. * PangoAttrLanguage:
  355. * @attr: the common portion of the attribute
  356. * @value: the `PangoLanguage` which is the value of the attribute
  357. *
  358. * The `PangoAttrLanguage` structure is used to represent attributes that
  359. * are languages.
  360. */
  361. struct _PangoAttrLanguage
  362. {
  363. PangoAttribute attr;
  364. PangoLanguage *value;
  365. };
  366. /**
  367. * PangoAttrInt:
  368. * @attr: the common portion of the attribute
  369. * @value: the value of the attribute
  370. *
  371. * The `PangoAttrInt` structure is used to represent attributes with
  372. * an integer or enumeration value.
  373. */
  374. struct _PangoAttrInt
  375. {
  376. PangoAttribute attr;
  377. int value;
  378. };
  379. /**
  380. * PangoAttrFloat:
  381. * @attr: the common portion of the attribute
  382. * @value: the value of the attribute
  383. *
  384. * The `PangoAttrFloat` structure is used to represent attributes with
  385. * a float or double value.
  386. */
  387. struct _PangoAttrFloat
  388. {
  389. PangoAttribute attr;
  390. double value;
  391. };
  392. /**
  393. * PangoAttrColor:
  394. * @attr: the common portion of the attribute
  395. * @color: the `PangoColor` which is the value of the attribute
  396. *
  397. * The `PangoAttrColor` structure is used to represent attributes that
  398. * are colors.
  399. */
  400. struct _PangoAttrColor
  401. {
  402. PangoAttribute attr;
  403. PangoColor color;
  404. };
  405. /**
  406. * PangoAttrSize:
  407. * @attr: the common portion of the attribute
  408. * @size: size of font, in units of 1/%PANGO_SCALE of a point (for
  409. * %PANGO_ATTR_SIZE) or of a device unit (for %PANGO_ATTR_ABSOLUTE_SIZE)
  410. * @absolute: whether the font size is in device units or points.
  411. * This field is only present for compatibility with Pango-1.8.0
  412. * (%PANGO_ATTR_ABSOLUTE_SIZE was added in 1.8.1); and always will
  413. * be %FALSE for %PANGO_ATTR_SIZE and %TRUE for %PANGO_ATTR_ABSOLUTE_SIZE.
  414. *
  415. * The `PangoAttrSize` structure is used to represent attributes which
  416. * set font size.
  417. */
  418. struct _PangoAttrSize
  419. {
  420. PangoAttribute attr;
  421. int size;
  422. guint absolute : 1;
  423. };
  424. /**
  425. * PangoAttrShape:
  426. * @attr: the common portion of the attribute
  427. * @ink_rect: the ink rectangle to restrict to
  428. * @logical_rect: the logical rectangle to restrict to
  429. * @data: user data set (see [func@Pango.AttrShape.new_with_data])
  430. * @copy_func: copy function for the user data
  431. * @destroy_func: destroy function for the user data
  432. *
  433. * The `PangoAttrShape` structure is used to represent attributes which
  434. * impose shape restrictions.
  435. */
  436. struct _PangoAttrShape
  437. {
  438. PangoAttribute attr;
  439. PangoRectangle ink_rect;
  440. PangoRectangle logical_rect;
  441. gpointer data;
  442. PangoAttrDataCopyFunc copy_func;
  443. GDestroyNotify destroy_func;
  444. };
  445. /**
  446. * PangoAttrFontDesc:
  447. * @attr: the common portion of the attribute
  448. * @desc: the font description which is the value of this attribute
  449. *
  450. * The `PangoAttrFontDesc` structure is used to store an attribute that
  451. * sets all aspects of the font description at once.
  452. */
  453. struct _PangoAttrFontDesc
  454. {
  455. PangoAttribute attr;
  456. PangoFontDescription *desc;
  457. };
  458. /**
  459. * PangoAttrFontFeatures:
  460. * @attr: the common portion of the attribute
  461. * @features: the features, as a string in CSS syntax
  462. *
  463. * The `PangoAttrFontFeatures` structure is used to represent OpenType
  464. * font features as an attribute.
  465. *
  466. * Since: 1.38
  467. */
  468. struct _PangoAttrFontFeatures
  469. {
  470. PangoAttribute attr;
  471. gchar *features;
  472. };
  473. PANGO_AVAILABLE_IN_ALL
  474. GType pango_attribute_get_type (void) G_GNUC_CONST;
  475. PANGO_AVAILABLE_IN_ALL
  476. PangoAttrType pango_attr_type_register (const char *name);
  477. PANGO_AVAILABLE_IN_1_22
  478. const char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST;
  479. PANGO_AVAILABLE_IN_1_20
  480. void pango_attribute_init (PangoAttribute *attr,
  481. const PangoAttrClass *klass);
  482. PANGO_AVAILABLE_IN_ALL
  483. PangoAttribute * pango_attribute_copy (const PangoAttribute *attr);
  484. PANGO_AVAILABLE_IN_ALL
  485. void pango_attribute_destroy (PangoAttribute *attr);
  486. PANGO_AVAILABLE_IN_ALL
  487. gboolean pango_attribute_equal (const PangoAttribute *attr1,
  488. const PangoAttribute *attr2) G_GNUC_PURE;
  489. PANGO_AVAILABLE_IN_ALL
  490. PangoAttribute * pango_attr_language_new (PangoLanguage *language);
  491. PANGO_AVAILABLE_IN_ALL
  492. PangoAttribute * pango_attr_family_new (const char *family);
  493. PANGO_AVAILABLE_IN_ALL
  494. PangoAttribute * pango_attr_foreground_new (guint16 red,
  495. guint16 green,
  496. guint16 blue);
  497. PANGO_AVAILABLE_IN_ALL
  498. PangoAttribute * pango_attr_background_new (guint16 red,
  499. guint16 green,
  500. guint16 blue);
  501. PANGO_AVAILABLE_IN_ALL
  502. PangoAttribute * pango_attr_size_new (int size);
  503. PANGO_AVAILABLE_IN_1_8
  504. PangoAttribute * pango_attr_size_new_absolute (int size);
  505. PANGO_AVAILABLE_IN_ALL
  506. PangoAttribute * pango_attr_style_new (PangoStyle style);
  507. PANGO_AVAILABLE_IN_ALL
  508. PangoAttribute * pango_attr_weight_new (PangoWeight weight);
  509. PANGO_AVAILABLE_IN_ALL
  510. PangoAttribute * pango_attr_variant_new (PangoVariant variant);
  511. PANGO_AVAILABLE_IN_ALL
  512. PangoAttribute * pango_attr_stretch_new (PangoStretch stretch);
  513. PANGO_AVAILABLE_IN_ALL
  514. PangoAttribute * pango_attr_font_desc_new (const PangoFontDescription *desc);
  515. PANGO_AVAILABLE_IN_ALL
  516. PangoAttribute * pango_attr_underline_new (PangoUnderline underline);
  517. PANGO_AVAILABLE_IN_1_8
  518. PangoAttribute * pango_attr_underline_color_new (guint16 red,
  519. guint16 green,
  520. guint16 blue);
  521. PANGO_AVAILABLE_IN_ALL
  522. PangoAttribute * pango_attr_strikethrough_new (gboolean strikethrough);
  523. PANGO_AVAILABLE_IN_1_8
  524. PangoAttribute * pango_attr_strikethrough_color_new (guint16 red,
  525. guint16 green,
  526. guint16 blue);
  527. PANGO_AVAILABLE_IN_ALL
  528. PangoAttribute * pango_attr_rise_new (int rise);
  529. PANGO_AVAILABLE_IN_1_50
  530. PangoAttribute * pango_attr_baseline_shift_new (int shift);
  531. PANGO_AVAILABLE_IN_1_50
  532. PangoAttribute * pango_attr_font_scale_new (PangoFontScale scale);
  533. PANGO_AVAILABLE_IN_ALL
  534. PangoAttribute * pango_attr_scale_new (double scale_factor);
  535. PANGO_AVAILABLE_IN_1_4
  536. PangoAttribute * pango_attr_fallback_new (gboolean enable_fallback);
  537. PANGO_AVAILABLE_IN_1_6
  538. PangoAttribute * pango_attr_letter_spacing_new (int letter_spacing);
  539. PANGO_AVAILABLE_IN_ALL
  540. PangoAttribute * pango_attr_shape_new (const PangoRectangle *ink_rect,
  541. const PangoRectangle *logical_rect);
  542. PANGO_AVAILABLE_IN_1_8
  543. PangoAttribute * pango_attr_shape_new_with_data (const PangoRectangle *ink_rect,
  544. const PangoRectangle *logical_rect,
  545. gpointer data,
  546. PangoAttrDataCopyFunc copy_func,
  547. GDestroyNotify destroy_func);
  548. PANGO_AVAILABLE_IN_1_16
  549. PangoAttribute * pango_attr_gravity_new (PangoGravity gravity);
  550. PANGO_AVAILABLE_IN_1_16
  551. PangoAttribute * pango_attr_gravity_hint_new (PangoGravityHint hint);
  552. PANGO_AVAILABLE_IN_1_38
  553. PangoAttribute * pango_attr_font_features_new (const char *features);
  554. PANGO_AVAILABLE_IN_1_38
  555. PangoAttribute * pango_attr_foreground_alpha_new (guint16 alpha);
  556. PANGO_AVAILABLE_IN_1_38
  557. PangoAttribute * pango_attr_background_alpha_new (guint16 alpha);
  558. PANGO_AVAILABLE_IN_1_44
  559. PangoAttribute * pango_attr_allow_breaks_new (gboolean allow_breaks);
  560. PANGO_AVAILABLE_IN_1_50
  561. PangoAttribute * pango_attr_word_new (void);
  562. PANGO_AVAILABLE_IN_1_50
  563. PangoAttribute * pango_attr_sentence_new (void);
  564. PANGO_AVAILABLE_IN_1_44
  565. PangoAttribute * pango_attr_insert_hyphens_new (gboolean insert_hyphens);
  566. PANGO_AVAILABLE_IN_1_46
  567. PangoAttribute * pango_attr_overline_new (PangoOverline overline);
  568. PANGO_AVAILABLE_IN_1_46
  569. PangoAttribute * pango_attr_overline_color_new (guint16 red,
  570. guint16 green,
  571. guint16 blue);
  572. PANGO_AVAILABLE_IN_1_44
  573. PangoAttribute * pango_attr_show_new (PangoShowFlags flags);
  574. PANGO_AVAILABLE_IN_1_50
  575. PangoAttribute * pango_attr_line_height_new (double factor);
  576. PANGO_AVAILABLE_IN_1_50
  577. PangoAttribute * pango_attr_line_height_new_absolute (int height);
  578. PANGO_AVAILABLE_IN_1_50
  579. PangoAttribute * pango_attr_text_transform_new (PangoTextTransform transform);
  580. PANGO_AVAILABLE_IN_1_50
  581. PangoAttrString * pango_attribute_as_string (PangoAttribute *attr);
  582. PANGO_AVAILABLE_IN_1_50
  583. PangoAttrLanguage * pango_attribute_as_language (PangoAttribute *attr);
  584. PANGO_AVAILABLE_IN_1_50
  585. PangoAttrInt * pango_attribute_as_int (PangoAttribute *attr);
  586. PANGO_AVAILABLE_IN_1_50
  587. PangoAttrSize * pango_attribute_as_size (PangoAttribute *attr);
  588. PANGO_AVAILABLE_IN_1_50
  589. PangoAttrFloat * pango_attribute_as_float (PangoAttribute *attr);
  590. PANGO_AVAILABLE_IN_1_50
  591. PangoAttrColor * pango_attribute_as_color (PangoAttribute *attr);
  592. PANGO_AVAILABLE_IN_1_50
  593. PangoAttrFontDesc * pango_attribute_as_font_desc (PangoAttribute *attr);
  594. PANGO_AVAILABLE_IN_1_50
  595. PangoAttrShape * pango_attribute_as_shape (PangoAttribute *attr);
  596. PANGO_AVAILABLE_IN_1_50
  597. PangoAttrFontFeatures * pango_attribute_as_font_features (PangoAttribute *attr);
  598. /* Attribute lists */
  599. typedef struct _PangoAttrList PangoAttrList;
  600. typedef struct _PangoAttrIterator PangoAttrIterator;
  601. #define PANGO_TYPE_ATTR_LIST pango_attr_list_get_type ()
  602. /**
  603. * PangoAttrIterator:
  604. *
  605. * A `PangoAttrIterator` is used to iterate through a `PangoAttrList`.
  606. *
  607. * A new iterator is created with [method@Pango.AttrList.get_iterator].
  608. * Once the iterator is created, it can be advanced through the style
  609. * changes in the text using [method@Pango.AttrIterator.next]. At each
  610. * style change, the range of the current style segment and the attributes
  611. * currently in effect can be queried.
  612. */
  613. /**
  614. * PangoAttrList:
  615. *
  616. * A `PangoAttrList` represents a list of attributes that apply to a section
  617. * of text.
  618. *
  619. * The attributes in a `PangoAttrList` are, in general, allowed to overlap in
  620. * an arbitrary fashion. However, if the attributes are manipulated only through
  621. * [method@Pango.AttrList.change], the overlap between properties will meet
  622. * stricter criteria.
  623. *
  624. * Since the `PangoAttrList` structure is stored as a linear list, it is not
  625. * suitable for storing attributes for large amounts of text. In general, you
  626. * should not use a single `PangoAttrList` for more than one paragraph of text.
  627. */
  628. PANGO_AVAILABLE_IN_ALL
  629. GType pango_attr_list_get_type (void) G_GNUC_CONST;
  630. PANGO_AVAILABLE_IN_ALL
  631. PangoAttrList * pango_attr_list_new (void);
  632. PANGO_AVAILABLE_IN_1_10
  633. PangoAttrList * pango_attr_list_ref (PangoAttrList *list);
  634. PANGO_AVAILABLE_IN_ALL
  635. void pango_attr_list_unref (PangoAttrList *list);
  636. PANGO_AVAILABLE_IN_ALL
  637. PangoAttrList * pango_attr_list_copy (PangoAttrList *list);
  638. PANGO_AVAILABLE_IN_ALL
  639. void pango_attr_list_insert (PangoAttrList *list,
  640. PangoAttribute *attr);
  641. PANGO_AVAILABLE_IN_ALL
  642. void pango_attr_list_insert_before (PangoAttrList *list,
  643. PangoAttribute *attr);
  644. PANGO_AVAILABLE_IN_ALL
  645. void pango_attr_list_change (PangoAttrList *list,
  646. PangoAttribute *attr);
  647. PANGO_AVAILABLE_IN_ALL
  648. void pango_attr_list_splice (PangoAttrList *list,
  649. PangoAttrList *other,
  650. int pos,
  651. int len);
  652. PANGO_AVAILABLE_IN_1_44
  653. void pango_attr_list_update (PangoAttrList *list,
  654. int pos,
  655. int remove,
  656. int add);
  657. PANGO_AVAILABLE_IN_1_2
  658. PangoAttrList * pango_attr_list_filter (PangoAttrList *list,
  659. PangoAttrFilterFunc func,
  660. gpointer data);
  661. PANGO_AVAILABLE_IN_1_44
  662. GSList * pango_attr_list_get_attributes (PangoAttrList *list);
  663. PANGO_AVAILABLE_IN_1_46
  664. gboolean pango_attr_list_equal (PangoAttrList *list,
  665. PangoAttrList *other_list);
  666. PANGO_AVAILABLE_IN_1_50
  667. char * pango_attr_list_to_string (PangoAttrList *list);
  668. PANGO_AVAILABLE_IN_1_50
  669. PangoAttrList * pango_attr_list_from_string (const char *text);
  670. PANGO_AVAILABLE_IN_1_44
  671. GType pango_attr_iterator_get_type (void) G_GNUC_CONST;
  672. PANGO_AVAILABLE_IN_ALL
  673. PangoAttrIterator * pango_attr_list_get_iterator (PangoAttrList *list);
  674. PANGO_AVAILABLE_IN_ALL
  675. void pango_attr_iterator_range (PangoAttrIterator *iterator,
  676. int *start,
  677. int *end);
  678. PANGO_AVAILABLE_IN_ALL
  679. gboolean pango_attr_iterator_next (PangoAttrIterator *iterator);
  680. PANGO_AVAILABLE_IN_ALL
  681. PangoAttrIterator * pango_attr_iterator_copy (PangoAttrIterator *iterator);
  682. PANGO_AVAILABLE_IN_ALL
  683. void pango_attr_iterator_destroy (PangoAttrIterator *iterator);
  684. PANGO_AVAILABLE_IN_ALL
  685. PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator,
  686. PangoAttrType type);
  687. PANGO_AVAILABLE_IN_ALL
  688. void pango_attr_iterator_get_font (PangoAttrIterator *iterator,
  689. PangoFontDescription *desc,
  690. PangoLanguage **language,
  691. GSList **extra_attrs);
  692. PANGO_AVAILABLE_IN_1_2
  693. GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
  694. G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoAttribute, pango_attribute_destroy)
  695. G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoAttrList, pango_attr_list_unref)
  696. G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoAttrIterator, pango_attr_iterator_destroy)
  697. G_END_DECLS
  698. #endif /* __PANGO_ATTRIBUTES_H__ */