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

source code of include/pango-1.0/pango/pango-gravity.h