1 /*
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 */6 modulepango.gravity;
7 8 importpango.matrix;
9 importpango.script;
10 importpango.c.gravity;
11 importpango.c.script;
12 13 14 15 /**
16 * Gravity:
17 * South: Glyphs stand upright (default)
18 * East: Glyphs are rotated 90 degrees clockwise
19 * North: Glyphs are upside-down
20 * West: Glyphs are rotated 90 degrees counter-clockwise
21 * Auto: Gravity is resolved from the context matrix
22 *
23 * The #PangoGravity type represents the orientation of glyphs in a segment
24 * of text. This is useful when rendering vertical text layouts. In
25 * those situations, the layout is rotated using a non-identity PangoMatrix,
26 * and then glyph orientation is controlled using #PangoGravity.
27 * Not every value in this enumeration makes sense for every usage of
28 * #PangoGravity; for example, %PANGO_GRAVITY_AUTO only can be passed to
29 * pango_context_set_base_gravity() and can only be returned by
30 * pango_context_get_base_gravity().
31 *
32 * See also: #PangoGravityHint
33 *
34 * Since: 1.16
35 **/36 enumGravity {
37 South = PangoGravity.PANGO_GRAVITY_SOUTH,
38 East = PangoGravity.PANGO_GRAVITY_EAST,
39 North = PangoGravity.PANGO_GRAVITY_NORTH,
40 West = PangoGravity.PANGO_GRAVITY_WEST,
41 Auto = PangoGravity.PANGO_GRAVITY_AUTO42 }
43 44 /**
45 * GravityHint:
46 * Natural: scripts will take their natural gravity based
47 * on the base gravity and the script. This is the default.
48 * Strong: always use the base gravity set, regardless of
49 * the script.
50 * Line: for scripts not in their natural direction (eg.
51 * Latin in East gravity), choose per-script gravity such that every script
52 * respects the line progression. This means, Latin and Arabic will take
53 * opposite gravities and both flow top-to-bottom for example.
54 *
55 * The #PangoGravityHint defines how horizontal scripts should behave in a
56 * vertical context. That is, English excerpt in a vertical paragraph for
57 * example.
58 *
59 * See #PangoGravity.
60 *
61 * Since: 1.16
62 **/63 enumGravityHint {
64 Natural = PangoGravityHint.PANGO_GRAVITY_HINT_NATURAL,
65 Strong = PangoGravityHint.PANGO_GRAVITY_HINT_STRONG,
66 Line = PangoGravityHint.PANGO_GRAVITY_HINT_LINE67 }
68 69 /**
70 * PANGO_GRAVITY_IS_VERTICAL:
71 * @gravity: the #PangoGravity to check
72 *
73 * Whether a #PangoGravity represents vertical writing directions.
74 *
75 * Returns: %TRUE if @gravity is %PANGO_GRAVITY_EAST or %PANGO_GRAVITY_WEST,
76 * %FALSE otherwise.
77 *
78 * Since: 1.16
79 **/80 @propertyboolvertical(Gravitygravity) {
81 returngravity == Gravity.East || gravity == Gravity.West;
82 }
83 84 /**
85 * PANGO_GRAVITY_IS_IMPROPER:
86 * @gravity: the #PangoGravity to check
87 *
88 * Whether a #PangoGravity represents a gravity that results in reversal of text direction.
89 *
90 * Returns: %TRUE if @gravity is %PANGO_GRAVITY_WEST or %PANGO_GRAVITY_NORTH,
91 * %FALSE otherwise.
92 *
93 * Since: 1.32
94 **/95 @propertyboolimproper(Gravitygravity) {
96 returngravity == Gravity.West || gravity == Gravity.North;
97 }
98 99 100 pure @propertydoublerotation(Gravitygravity) {
101 returnpango_gravity_to_rotation(cast(PangoGravity)gravity);
102 }
103 104 pureGravitygravityForMatrix(const(Matrix) matrix) {
105 returncast(Gravity)pango_gravity_get_for_matrix(matrix.nativePtr);
106 }
107 108 pureGravitygravityForScript(Scriptscript, GravitybaseGravity, GravityHinthint) {
109 returncast(Gravity)pango_gravity_get_for_script(cast(PangoScript) script,
110 cast(PangoGravity) baseGravity,
111 cast(PangoGravityHint)hint);
112 }
113 114 pureGravitygravityForScriptAndWidth(Scriptscript, boolwide,
115 GravitybaseGravity, GravityHinthint) {
116 returncast(Gravity)
117 pango_gravity_get_for_script_and_width(cast(PangoScript) script, wide,
118 cast(PangoGravity) baseGravity,
119 cast(PangoGravityHint)hint);
120 }
121