pango-gravity.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* Pango
  2. * pango-gravity.h: Gravity routines
  3. *
  4. * Copyright (C) 2006, 2007 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_GRAVITY_H__
  22. #define __PANGO_GRAVITY_H__
  23. #include <glib.h>
  24. G_BEGIN_DECLS
  25. /**
  26. * PangoGravity:
  27. * @PANGO_GRAVITY_SOUTH: Glyphs stand upright (default) <img align="right" valign="center" src="m-south.png">
  28. * @PANGO_GRAVITY_EAST: Glyphs are rotated 90 degrees counter-clockwise. <img align="right" valign="center" src="m-east.png">
  29. * @PANGO_GRAVITY_NORTH: Glyphs are upside-down. <img align="right" valign="cener" src="m-north.png">
  30. * @PANGO_GRAVITY_WEST: Glyphs are rotated 90 degrees clockwise. <img align="right" valign="center" src="m-west.png">
  31. * @PANGO_GRAVITY_AUTO: Gravity is resolved from the context matrix
  32. *
  33. * `PangoGravity` represents the orientation of glyphs in a segment
  34. * of text.
  35. *
  36. * This is useful when rendering vertical text layouts. In those situations,
  37. * the layout is rotated using a non-identity [struct@Pango.Matrix], and then
  38. * glyph orientation is controlled using `PangoGravity`.
  39. *
  40. * Not every value in this enumeration makes sense for every usage of
  41. * `PangoGravity`; for example, %PANGO_GRAVITY_AUTO only can be passed to
  42. * [method@Pango.Context.set_base_gravity] and can only be returned by
  43. * [method@Pango.Context.get_base_gravity].
  44. *
  45. * See also: [enum@Pango.GravityHint]
  46. *
  47. * Since: 1.16
  48. */
  49. typedef enum {
  50. PANGO_GRAVITY_SOUTH,
  51. PANGO_GRAVITY_EAST,
  52. PANGO_GRAVITY_NORTH,
  53. PANGO_GRAVITY_WEST,
  54. PANGO_GRAVITY_AUTO
  55. } PangoGravity;
  56. /**
  57. * PangoGravityHint:
  58. * @PANGO_GRAVITY_HINT_NATURAL: scripts will take their natural gravity based
  59. * on the base gravity and the script. This is the default.
  60. * @PANGO_GRAVITY_HINT_STRONG: always use the base gravity set, regardless of
  61. * the script.
  62. * @PANGO_GRAVITY_HINT_LINE: for scripts not in their natural direction (eg.
  63. * Latin in East gravity), choose per-script gravity such that every script
  64. * respects the line progression. This means, Latin and Arabic will take
  65. * opposite gravities and both flow top-to-bottom for example.
  66. *
  67. * `PangoGravityHint` defines how horizontal scripts should behave in a
  68. * vertical context.
  69. *
  70. * That is, English excerpts in a vertical paragraph for example.
  71. *
  72. * See also [enum@Pango.Gravity]
  73. *
  74. * Since: 1.16
  75. */
  76. typedef enum {
  77. PANGO_GRAVITY_HINT_NATURAL,
  78. PANGO_GRAVITY_HINT_STRONG,
  79. PANGO_GRAVITY_HINT_LINE
  80. } PangoGravityHint;
  81. /**
  82. * PANGO_GRAVITY_IS_VERTICAL:
  83. * @gravity: the `PangoGravity` to check
  84. *
  85. * Whether a `PangoGravity` represents vertical writing directions.
  86. *
  87. * Returns: %TRUE if @gravity is %PANGO_GRAVITY_EAST or %PANGO_GRAVITY_WEST,
  88. * %FALSE otherwise.
  89. *
  90. * Since: 1.16
  91. */
  92. #define PANGO_GRAVITY_IS_VERTICAL(gravity) \
  93. ((gravity) == PANGO_GRAVITY_EAST || (gravity) == PANGO_GRAVITY_WEST)
  94. /**
  95. * PANGO_GRAVITY_IS_IMPROPER:
  96. * @gravity: the `PangoGravity` to check
  97. *
  98. * Whether a `PangoGravity` represents a gravity that results in reversal
  99. * of text direction.
  100. *
  101. * Returns: %TRUE if @gravity is %PANGO_GRAVITY_WEST or %PANGO_GRAVITY_NORTH,
  102. * %FALSE otherwise.
  103. *
  104. * Since: 1.32
  105. */
  106. #define PANGO_GRAVITY_IS_IMPROPER(gravity) \
  107. ((gravity) == PANGO_GRAVITY_WEST || (gravity) == PANGO_GRAVITY_NORTH)
  108. #include <pango/pango-matrix.h>
  109. #include <pango/pango-script.h>
  110. PANGO_AVAILABLE_IN_1_16
  111. double pango_gravity_to_rotation (PangoGravity gravity) G_GNUC_CONST;
  112. PANGO_AVAILABLE_IN_1_16
  113. PangoGravity pango_gravity_get_for_matrix (const PangoMatrix *matrix) G_GNUC_PURE;
  114. PANGO_AVAILABLE_IN_1_16
  115. PangoGravity pango_gravity_get_for_script (PangoScript script,
  116. PangoGravity base_gravity,
  117. PangoGravityHint hint) G_GNUC_CONST;
  118. PANGO_AVAILABLE_IN_1_26
  119. PangoGravity pango_gravity_get_for_script_and_width
  120. (PangoScript script,
  121. gboolean wide,
  122. PangoGravity base_gravity,
  123. PangoGravityHint hint) G_GNUC_CONST;
  124. G_END_DECLS
  125. #endif /* __PANGO_GRAVITY_H__ */