1// Package pango was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package pango
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// A `PangoGlyphItem` is a pair of a `PangoItem` and the glyphs
16// resulting from shaping the items text.
17//
18// As an example of the usage of `PangoGlyphItem`, the results
19// of shaping text with `PangoLayout` is a list of `PangoLayoutLine`,
20// each of which contains a list of `PangoGlyphItem`.
21type GlyphItem struct {
22 _ structs.HostLayout
23
24 Item *Item
25
26 Glyphs *GlyphString
27
28 YOffset int
29
30 StartXOffset int
31
32 EndXOffset int
33}
34
35var xGlyphItemGLibType func() types.GType
36
37func GlyphItemGLibType() types.GType {
38 return xGlyphItemGLibType()
39}
40
41func (x *GlyphItem) GoPointer() uintptr {
42 return uintptr(unsafe.Pointer(x))
43}
44
45var xGlyphItemApplyAttrs func(uintptr, string, *AttrList) *glib.SList
46
47// Splits a shaped item (`PangoGlyphItem`) into multiple items based
48// on an attribute list.
49//
50// The idea is that if you have attributes that don't affect shaping,
51// such as color or underline, to avoid affecting shaping, you filter
52// them out ([method@Pango.AttrList.filter]), apply the shaping process
53// and then reapply them to the result using this function.
54//
55// All attributes that start or end inside a cluster are applied
56// to that cluster; for instance, if half of a cluster is underlined
57// and the other-half strikethrough, then the cluster will end
58// up with both underline and strikethrough attributes. In these
59// cases, it may happen that @item->extra_attrs for some of the
60// result items can have multiple attributes of the same type.
61//
62// This function takes ownership of @glyph_item; it will be reused
63// as one of the elements in the list.
64func (x *GlyphItem) ApplyAttrs(TextVar string, ListVar *AttrList) *glib.SList {
65
66 cret := xGlyphItemApplyAttrs(x.GoPointer(), TextVar, ListVar)
67 return cret
68}
69
70var xGlyphItemCopy func(uintptr) *GlyphItem
71
72// Make a deep copy of an existing `PangoGlyphItem` structure.
73func (x *GlyphItem) Copy() *GlyphItem {
74
75 cret := xGlyphItemCopy(x.GoPointer())
76 return cret
77}
78
79var xGlyphItemFree func(uintptr)
80
81// Frees a `PangoGlyphItem` and resources to which it points.
82func (x *GlyphItem) Free() {
83
84 xGlyphItemFree(x.GoPointer())
85
86}
87
88var xGlyphItemGetLogicalWidths func(uintptr, string, *[]int)
89
90// Given a `PangoGlyphItem` and the corresponding text, determine the
91// width corresponding to each character.
92//
93// When multiple characters compose a single cluster, the width of the
94// entire cluster is divided equally among the characters.
95//
96// See also [method@Pango.GlyphString.get_logical_widths].
97func (x *GlyphItem) GetLogicalWidths(TextVar string, LogicalWidthsVar *[]int) {
98
99 xGlyphItemGetLogicalWidths(x.GoPointer(), TextVar, LogicalWidthsVar)
100
101}
102
103var xGlyphItemLetterSpace func(uintptr, string, []LogAttr, int)
104
105// Adds spacing between the graphemes of @glyph_item to
106// give the effect of typographic letter spacing.
107func (x *GlyphItem) LetterSpace(TextVar string, LogAttrsVar []LogAttr, LetterSpacingVar int) {
108
109 xGlyphItemLetterSpace(x.GoPointer(), TextVar, LogAttrsVar, LetterSpacingVar)
110
111}
112
113var xGlyphItemSplit func(uintptr, string, int) *GlyphItem
114
115// Modifies @orig to cover only the text after @split_index, and
116// returns a new item that covers the text before @split_index that
117// used to be in @orig.
118//
119// You can think of @split_index as the length of the returned item.
120// @split_index may not be 0, and it may not be greater than or equal
121// to the length of @orig (that is, there must be at least one byte
122// assigned to each item, you can't create a zero-length item).
123//
124// This function is similar in function to pango_item_split() (and uses
125// it internally.)
126func (x *GlyphItem) Split(TextVar string, SplitIndexVar int) *GlyphItem {
127
128 cret := xGlyphItemSplit(x.GoPointer(), TextVar, SplitIndexVar)
129 return cret
130}
131
132// A `PangoGlyphItemIter` is an iterator over the clusters in a
133// `PangoGlyphItem`.
134//
135// The *forward direction* of the iterator is the logical direction of text.
136// That is, with increasing @start_index and @start_char values. If @glyph_item
137// is right-to-left (that is, if `glyph_item->item->analysis.level` is odd),
138// then @start_glyph decreases as the iterator moves forward. Moreover,
139// in right-to-left cases, @start_glyph is greater than @end_glyph.
140//
141// An iterator should be initialized using either
142// pango_glyph_item_iter_init_start() or
143// pango_glyph_item_iter_init_end(), for forward and backward iteration
144// respectively, and walked over using any desired mixture of
145// pango_glyph_item_iter_next_cluster() and
146// pango_glyph_item_iter_prev_cluster().
147//
148// A common idiom for doing a forward iteration over the clusters is:
149//
150// ```
151// PangoGlyphItemIter cluster_iter;
152// gboolean have_cluster;
153//
154// for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
155//
156// glyph_item, text);
157// have_cluster;
158// have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
159//
160// {
161// ...
162// }
163//
164// ```
165//
166// Note that @text is the start of the text for layout, which is then
167// indexed by `glyph_item->item->offset` to get to the text of @glyph_item.
168// The @start_index and @end_index values can directly index into @text. The
169// @start_glyph, @end_glyph, @start_char, and @end_char values however are
170// zero-based for the @glyph_item. For each cluster, the item pointed at by
171// the start variables is included in the cluster while the one pointed at by
172// end variables is not.
173//
174// None of the members of a `PangoGlyphItemIter` should be modified manually.
175type GlyphItemIter struct {
176 _ structs.HostLayout
177
178 GlyphItem *GlyphItem
179
180 Text uintptr
181
182 StartGlyph int
183
184 StartIndex int
185
186 StartChar int
187
188 EndGlyph int
189
190 EndIndex int
191
192 EndChar int
193}
194
195var xGlyphItemIterGLibType func() types.GType
196
197func GlyphItemIterGLibType() types.GType {
198 return xGlyphItemIterGLibType()
199}
200
201func (x *GlyphItemIter) GoPointer() uintptr {
202 return uintptr(unsafe.Pointer(x))
203}
204
205var xGlyphItemIterCopy func(uintptr) *GlyphItemIter
206
207// Make a shallow copy of an existing `PangoGlyphItemIter` structure.
208func (x *GlyphItemIter) Copy() *GlyphItemIter {
209
210 cret := xGlyphItemIterCopy(x.GoPointer())
211 return cret
212}
213
214var xGlyphItemIterFree func(uintptr)
215
216// Frees a `PangoGlyphItem`Iter.
217func (x *GlyphItemIter) Free() {
218
219 xGlyphItemIterFree(x.GoPointer())
220
221}
222
223var xGlyphItemIterInitEnd func(uintptr, *GlyphItem, string) bool
224
225// Initializes a `PangoGlyphItemIter` structure to point to the
226// last cluster in a glyph item.
227//
228// See `PangoGlyphItemIter` for details of cluster orders.
229func (x *GlyphItemIter) InitEnd(GlyphItemVar *GlyphItem, TextVar string) bool {
230
231 cret := xGlyphItemIterInitEnd(x.GoPointer(), GlyphItemVar, TextVar)
232 return cret
233}
234
235var xGlyphItemIterInitStart func(uintptr, *GlyphItem, string) bool
236
237// Initializes a `PangoGlyphItemIter` structure to point to the
238// first cluster in a glyph item.
239//
240// See `PangoGlyphItemIter` for details of cluster orders.
241func (x *GlyphItemIter) InitStart(GlyphItemVar *GlyphItem, TextVar string) bool {
242
243 cret := xGlyphItemIterInitStart(x.GoPointer(), GlyphItemVar, TextVar)
244 return cret
245}
246
247var xGlyphItemIterNextCluster func(uintptr) bool
248
249// Advances the iterator to the next cluster in the glyph item.
250//
251// See `PangoGlyphItemIter` for details of cluster orders.
252func (x *GlyphItemIter) NextCluster() bool {
253
254 cret := xGlyphItemIterNextCluster(x.GoPointer())
255 return cret
256}
257
258var xGlyphItemIterPrevCluster func(uintptr) bool
259
260// Moves the iterator to the preceding cluster in the glyph item.
261// See `PangoGlyphItemIter` for details of cluster orders.
262func (x *GlyphItemIter) PrevCluster() bool {
263
264 cret := xGlyphItemIterPrevCluster(x.GoPointer())
265 return cret
266}
267
268func init() {
269 core.SetPackageName("PANGO", "pango")
270 core.SetSharedLibraries("PANGO", []string{"libpango-1.0.so.0"})
271 var libs []uintptr
272 for _, libPath := range core.GetPaths("PANGO") {
273 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
274 if err != nil {
275 panic(err)
276 }
277 libs = append(libs, lib)
278 }
279
280 core.PuregoSafeRegister(&xGlyphItemGLibType, libs, "pango_glyph_item_get_type")
281
282 core.PuregoSafeRegister(&xGlyphItemApplyAttrs, libs, "pango_glyph_item_apply_attrs")
283 core.PuregoSafeRegister(&xGlyphItemCopy, libs, "pango_glyph_item_copy")
284 core.PuregoSafeRegister(&xGlyphItemFree, libs, "pango_glyph_item_free")
285 core.PuregoSafeRegister(&xGlyphItemGetLogicalWidths, libs, "pango_glyph_item_get_logical_widths")
286 core.PuregoSafeRegister(&xGlyphItemLetterSpace, libs, "pango_glyph_item_letter_space")
287 core.PuregoSafeRegister(&xGlyphItemSplit, libs, "pango_glyph_item_split")
288
289 core.PuregoSafeRegister(&xGlyphItemIterGLibType, libs, "pango_glyph_item_iter_get_type")
290
291 core.PuregoSafeRegister(&xGlyphItemIterCopy, libs, "pango_glyph_item_iter_copy")
292 core.PuregoSafeRegister(&xGlyphItemIterFree, libs, "pango_glyph_item_iter_free")
293 core.PuregoSafeRegister(&xGlyphItemIterInitEnd, libs, "pango_glyph_item_iter_init_end")
294 core.PuregoSafeRegister(&xGlyphItemIterInitStart, libs, "pango_glyph_item_iter_init_start")
295 core.PuregoSafeRegister(&xGlyphItemIterNextCluster, libs, "pango_glyph_item_iter_next_cluster")
296 core.PuregoSafeRegister(&xGlyphItemIterPrevCluster, libs, "pango_glyph_item_iter_prev_cluster")
297
298}