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