1// Package pango was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package pango
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8 "github.com/bnema/puregotk/v4/gobject/types"
9)
10
11// `PangoGravity` represents the orientation of glyphs in a segment
12// of text.
13//
14// This is useful when rendering vertical text layouts. In those situations,
15// the layout is rotated using a non-identity [struct@Pango.Matrix], and then
16// glyph orientation is controlled using `PangoGravity`.
17//
18// Not every value in this enumeration makes sense for every usage of
19// `PangoGravity`; for example, %PANGO_GRAVITY_AUTO only can be passed to
20// [method@Pango.Context.set_base_gravity] and can only be returned by
21// [method@Pango.Context.get_base_gravity].
22//
23// See also: [enum@Pango.GravityHint]
24type Gravity int
25
26var xGravityGLibType func() types.GType
27
28func GravityGLibType() types.GType {
29 return xGravityGLibType()
30}
31
32const (
33
34 // Glyphs stand upright (default) <img align="right" valign="center" src="m-south.png">
35 GravitySouthValue Gravity = 0
36 // Glyphs are rotated 90 degrees counter-clockwise. <img align="right" valign="center" src="m-east.png">
37 GravityEastValue Gravity = 1
38 // Glyphs are upside-down. <img align="right" valign="cener" src="m-north.png">
39 GravityNorthValue Gravity = 2
40 // Glyphs are rotated 90 degrees clockwise. <img align="right" valign="center" src="m-west.png">
41 GravityWestValue Gravity = 3
42 // Gravity is resolved from the context matrix
43 GravityAutoValue Gravity = 4
44)
45
46// `PangoGravityHint` defines how horizontal scripts should behave in a
47// vertical context.
48//
49// That is, English excerpts in a vertical paragraph for example.
50//
51// See also [enum@Pango.Gravity]
52type GravityHint int
53
54var xGravityHintGLibType func() types.GType
55
56func GravityHintGLibType() types.GType {
57 return xGravityHintGLibType()
58}
59
60const (
61
62 // scripts will take their natural gravity based
63 // on the base gravity and the script. This is the default.
64 GravityHintNaturalValue GravityHint = 0
65 // always use the base gravity set, regardless of
66 // the script.
67 GravityHintStrongValue GravityHint = 1
68 // for scripts not in their natural direction (eg.
69 // Latin in East gravity), choose per-script gravity such that every script
70 // respects the line progression. This means, Latin and Arabic will take
71 // opposite gravities and both flow top-to-bottom for example.
72 GravityHintLineValue GravityHint = 2
73)
74
75var xGravityGetForMatrix func(*Matrix) Gravity
76
77// Finds the gravity that best matches the rotation component
78// in a `PangoMatrix`.
79func GravityGetForMatrix(MatrixVar *Matrix) Gravity {
80
81 cret := xGravityGetForMatrix(MatrixVar)
82 return cret
83}
84
85var xGravityGetForScript func(Script, Gravity, GravityHint) Gravity
86
87// Returns the gravity to use in laying out a `PangoItem`.
88//
89// The gravity is determined based on the script, base gravity, and hint.
90//
91// If @base_gravity is %PANGO_GRAVITY_AUTO, it is first replaced with the
92// preferred gravity of @script. To get the preferred gravity of a script,
93// pass %PANGO_GRAVITY_AUTO and %PANGO_GRAVITY_HINT_STRONG in.
94func GravityGetForScript(ScriptVar Script, BaseGravityVar Gravity, HintVar GravityHint) Gravity {
95
96 cret := xGravityGetForScript(ScriptVar, BaseGravityVar, HintVar)
97 return cret
98}
99
100var xGravityGetForScriptAndWidth func(Script, bool, Gravity, GravityHint) Gravity
101
102// Returns the gravity to use in laying out a single character
103// or `PangoItem`.
104//
105// The gravity is determined based on the script, East Asian width,
106// base gravity, and hint,
107//
108// This function is similar to [func@Pango.Gravity.get_for_script] except
109// that this function makes a distinction between narrow/half-width and
110// wide/full-width characters also. Wide/full-width characters always
111// stand *upright*, that is, they always take the base gravity,
112// whereas narrow/full-width characters are always rotated in vertical
113// context.
114//
115// If @base_gravity is %PANGO_GRAVITY_AUTO, it is first replaced with the
116// preferred gravity of @script.
117func GravityGetForScriptAndWidth(ScriptVar Script, WideVar bool, BaseGravityVar Gravity, HintVar GravityHint) Gravity {
118
119 cret := xGravityGetForScriptAndWidth(ScriptVar, WideVar, BaseGravityVar, HintVar)
120 return cret
121}
122
123var xGravityToRotation func(Gravity) float64
124
125// Converts a `PangoGravity` value to its natural rotation in radians.
126//
127// Note that [method@Pango.Matrix.rotate] takes angle in degrees, not radians.
128// So, to call [method@Pango.Matrix,rotate] with the output of this function
129// you should multiply it by (180. / G_PI).
130func GravityToRotation(GravityVar Gravity) float64 {
131
132 cret := xGravityToRotation(GravityVar)
133 return cret
134}
135
136func init() {
137 core.SetPackageName("PANGO", "pango")
138 core.SetSharedLibraries("PANGO", []string{"libpango-1.0.so.0"})
139 var libs []uintptr
140 for _, libPath := range core.GetPaths("PANGO") {
141 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
142 if err != nil {
143 panic(err)
144 }
145 libs = append(libs, lib)
146 }
147
148 core.PuregoSafeRegister(&xGravityGLibType, libs, "pango_gravity_get_type")
149
150 core.PuregoSafeRegister(&xGravityHintGLibType, libs, "pango_gravity_hint_get_type")
151
152 core.PuregoSafeRegister(&xGravityGetForMatrix, libs, "pango_gravity_get_for_matrix")
153 core.PuregoSafeRegister(&xGravityGetForScript, libs, "pango_gravity_get_for_script")
154 core.PuregoSafeRegister(&xGravityGetForScriptAndWidth, libs, "pango_gravity_get_for_script_and_width")
155 core.PuregoSafeRegister(&xGravityToRotation, libs, "pango_gravity_to_rotation")
156
157}