summaryrefslogtreecommitdiff
path: root/pango/pango-gravity.h
blob: c12fe1da0eab8e78d033aefa8eecc4df932f2360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * Copyright (C) 2006, 2007 Red Hat Software
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <glib.h>

G_BEGIN_DECLS

/**
 * Pango2Gravity:
 * @PANGO2_GRAVITY_SOUTH: Glyphs stand upright (default) <img align="right" valign="center" src="m-south.png">
 * @PANGO2_GRAVITY_EAST: Glyphs are rotated 90 degrees counter-clockwise. <img align="right" valign="center" src="m-east.png">
 * @PANGO2_GRAVITY_NORTH: Glyphs are upside-down. <img align="right" valign="cener" src="m-north.png">
 * @PANGO2_GRAVITY_WEST: Glyphs are rotated 90 degrees clockwise. <img align="right" valign="center" src="m-west.png">
 * @PANGO2_GRAVITY_AUTO: Gravity is resolved from the context matrix
 *
 * `Pango2Gravity` represents the orientation of glyphs in a segment
 * of text.
 *
 * This is useful when rendering vertical text layouts. In those situations,
 * the layout is rotated using a non-identity [struct@Pango2.Matrix], and then
 * glyph orientation is controlled using `Pango2Gravity`.
 *
 * Not every value in this enumeration makes sense for every usage of
 * `Pango2Gravity`; for example, %PANGO2_GRAVITY_AUTO only can be passed to
 * [method@Pango2.Context.set_base_gravity] and can only be returned by
 * [method@Pango2.Context.get_base_gravity].
 *
 * See also: [enum@Pango2.GravityHint]
 */
typedef enum {
  PANGO2_GRAVITY_SOUTH,
  PANGO2_GRAVITY_EAST,
  PANGO2_GRAVITY_NORTH,
  PANGO2_GRAVITY_WEST,
  PANGO2_GRAVITY_AUTO
} Pango2Gravity;

/**
 * Pango2GravityHint:
 * @PANGO2_GRAVITY_HINT_NATURAL: scripts will take their natural gravity based
 *   on the base gravity and the script.  This is the default.
 * @PANGO2_GRAVITY_HINT_STRONG: always use the base gravity set, regardless of
 *   the script.
 * @PANGO2_GRAVITY_HINT_LINE: for scripts not in their natural direction (eg.
 *   Latin in East gravity), choose per-script gravity such that every script
 *   respects the line progression. This means, Latin and Arabic will take
 *   opposite gravities and both flow top-to-bottom for example.
 *
 * `Pango2GravityHint` defines how horizontal scripts should behave in a
 * vertical context.
 *
 * That is, English excerpts in a vertical paragraph for example.
 *
 * See also [enum@Pango2.Gravity]
 */
typedef enum {
  PANGO2_GRAVITY_HINT_NATURAL,
  PANGO2_GRAVITY_HINT_STRONG,
  PANGO2_GRAVITY_HINT_LINE
} Pango2GravityHint;

/**
 * PANGO2_GRAVITY_IS_VERTICAL:
 * @gravity: the `Pango2Gravity` to check
 *
 * Whether a `Pango2Gravity` represents vertical writing directions.
 *
 * Returns: %TRUE if @gravity is %PANGO2_GRAVITY_EAST or %PANGO2_GRAVITY_WEST,
 *   %FALSE otherwise.
 */
#define PANGO2_GRAVITY_IS_VERTICAL(gravity) \
        ((gravity) == PANGO2_GRAVITY_EAST || (gravity) == PANGO2_GRAVITY_WEST)

/**
 * PANGO2_GRAVITY_IS_IMPROPER:
 * @gravity: the `Pango2Gravity` to check
 *
 * Whether a `Pango2Gravity` represents a gravity that results in reversal
 * of text direction.
 *
 * Returns: %TRUE if @gravity is %PANGO2_GRAVITY_WEST or %PANGO2_GRAVITY_NORTH,
 *   %FALSE otherwise.
 */
#define PANGO2_GRAVITY_IS_IMPROPER(gravity) \
        ((gravity) == PANGO2_GRAVITY_WEST || (gravity) == PANGO2_GRAVITY_NORTH)

#include <pango/pango-matrix.h>
#include <pango/pango-script.h>

PANGO2_AVAILABLE_IN_ALL
double                  pango2_gravity_to_rotation    (Pango2Gravity       gravity) G_GNUC_CONST;
PANGO2_AVAILABLE_IN_ALL
Pango2Gravity           pango2_gravity_get_for_matrix (const Pango2Matrix *matrix) G_GNUC_PURE;
PANGO2_AVAILABLE_IN_ALL
Pango2Gravity           pango2_gravity_get_for_script (GUnicodeScript      script,
                                                       Pango2Gravity       base_gravity,
                                                       Pango2GravityHint   hint) G_GNUC_CONST;
PANGO2_AVAILABLE_IN_ALL
Pango2Gravity           pango2_gravity_get_for_script_and_width
                                                      (GUnicodeScript      script,
                                                       gboolean            wide,
                                                       Pango2Gravity       base_gravity,
                                                       Pango2GravityHint   hint) G_GNUC_CONST;


G_END_DECLS