v0.2.2 9100209

pango-glyph.go RawHistoryFolder

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/gobject/types"
12)
13
14// The `PangoGlyphGeometry` structure contains width and positioning
15// information for a single glyph.
16//
17// Note that @width is not guaranteed to be the same as the glyph
18// extents. Kerning and other positioning applied during shaping will
19// affect both the @width and the @x_offset for the glyphs in the
20// glyph string that results from shaping.
21//
22// The information in this struct is intended for rendering the glyphs,
23// as follows:
24//
25// 1. Assume the current point is (x, y)
26// 2. Render the current glyph at (x + x_offset, y + y_offset),
27// 3. Advance the current point to (x + width, y)
28// 4. Render the next glyph
29type GlyphGeometry struct {
30	_ structs.HostLayout
31
32	Width GlyphUnit
33
34	XOffset GlyphUnit
35
36	YOffset GlyphUnit
37}
38
39func (x *GlyphGeometry) GoPointer() uintptr {
40	return uintptr(unsafe.Pointer(x))
41}
42
43// A `PangoGlyphInfo` structure represents a single glyph with
44// positioning information and visual attributes.
45type GlyphInfo struct {
46	_ structs.HostLayout
47
48	Glyph Glyph
49
50	Geometry uintptr
51
52	Attr uintptr
53}
54
55func (x *GlyphInfo) GoPointer() uintptr {
56	return uintptr(unsafe.Pointer(x))
57}
58
59// A `PangoGlyphString` is used to store strings of glyphs with geometry
60// and visual attribute information.
61//
62// The storage for the glyph information is owned by the structure
63// which simplifies memory management.
64type GlyphString struct {
65	_ structs.HostLayout
66
67	NumGlyphs int
68
69	Glyphs []GlyphInfo
70
71	LogClusters int
72
73	Space int
74}
75
76var xGlyphStringGLibType func() types.GType
77
78func GlyphStringGLibType() types.GType {
79	return xGlyphStringGLibType()
80}
81
82func (x *GlyphString) GoPointer() uintptr {
83	return uintptr(unsafe.Pointer(x))
84}
85
86var xNewGlyphString func() *GlyphString
87
88// Create a new `PangoGlyphString`.
89func NewGlyphString() *GlyphString {
90
91	cret := xNewGlyphString()
92	return cret
93}
94
95var xGlyphStringCopy func(uintptr) *GlyphString
96
97// Copy a glyph string and associated storage.
98func (x *GlyphString) Copy() *GlyphString {
99
100	cret := xGlyphStringCopy(x.GoPointer())
101	return cret
102}
103
104var xGlyphStringExtents func(uintptr, uintptr, *Rectangle, *Rectangle)
105
106// Compute the logical and ink extents of a glyph string.
107//
108// See the documentation for [method@Pango.Font.get_glyph_extents] for details
109// about the interpretation of the rectangles.
110//
111// Examples of logical (red) and ink (green) rects:
112//
113// ![](rects1.png) ![](rects2.png)
114func (x *GlyphString) Extents(FontVar *Font, InkRectVar *Rectangle, LogicalRectVar *Rectangle) {
115
116	xGlyphStringExtents(x.GoPointer(), FontVar.GoPointer(), InkRectVar, LogicalRectVar)
117
118}
119
120var xGlyphStringExtentsRange func(uintptr, int, int, uintptr, *Rectangle, *Rectangle)
121
122// Computes the extents of a sub-portion of a glyph string.
123//
124// The extents are relative to the start of the glyph string range
125// (the origin of their coordinate system is at the start of the range,
126// not at the start of the entire glyph string).
127func (x *GlyphString) ExtentsRange(StartVar int, EndVar int, FontVar *Font, InkRectVar *Rectangle, LogicalRectVar *Rectangle) {
128
129	xGlyphStringExtentsRange(x.GoPointer(), StartVar, EndVar, FontVar.GoPointer(), InkRectVar, LogicalRectVar)
130
131}
132
133var xGlyphStringFree func(uintptr)
134
135// Free a glyph string and associated storage.
136func (x *GlyphString) Free() {
137
138	xGlyphStringFree(x.GoPointer())
139
140}
141
142var xGlyphStringGetLogicalWidths func(uintptr, string, int, int, *[]int)
143
144// Given a `PangoGlyphString` and corresponding text, determine the width
145// corresponding to each character.
146//
147// When multiple characters compose a single cluster, the width of the
148// entire cluster is divided equally among the characters.
149//
150// See also [method@Pango.GlyphItem.get_logical_widths].
151func (x *GlyphString) GetLogicalWidths(TextVar string, LengthVar int, EmbeddingLevelVar int, LogicalWidthsVar *[]int) {
152
153	xGlyphStringGetLogicalWidths(x.GoPointer(), TextVar, LengthVar, EmbeddingLevelVar, LogicalWidthsVar)
154
155}
156
157var xGlyphStringGetWidth func(uintptr) int
158
159// Computes the logical width of the glyph string.
160//
161// This can also be computed using [method@Pango.GlyphString.extents].
162// However, since this only computes the width, it's much faster. This
163// is in fact only a convenience function that computes the sum of
164// @geometry.width for each glyph in the @glyphs.
165func (x *GlyphString) GetWidth() int {
166
167	cret := xGlyphStringGetWidth(x.GoPointer())
168	return cret
169}
170
171var xGlyphStringIndexToX func(uintptr, string, int, *Analysis, int, bool, *int)
172
173// Converts from character position to x position.
174//
175// The X position is measured from the left edge of the run.
176// Character positions are obtained using font metrics for ligatures
177// where available, and computed by dividing up each cluster
178// into equal portions, otherwise.
179//
180// <picture>
181//
182//	<source srcset="glyphstring-positions-dark.png" media="(prefers-color-scheme: dark)">
183//	<img alt="Glyph positions" src="glyphstring-positions-light.png">
184//
185// </picture>
186func (x *GlyphString) IndexToX(TextVar string, LengthVar int, AnalysisVar *Analysis, IndexVar int, TrailingVar bool, XPosVar *int) {
187
188	xGlyphStringIndexToX(x.GoPointer(), TextVar, LengthVar, AnalysisVar, IndexVar, TrailingVar, XPosVar)
189
190}
191
192var xGlyphStringIndexToXFull func(uintptr, string, int, *Analysis, *LogAttr, int, bool, *int)
193
194// Converts from character position to x position.
195//
196// This variant of [method@Pango.GlyphString.index_to_x] additionally
197// accepts a `PangoLogAttr` array. The grapheme boundary information
198// in it can be used to disambiguate positioning inside some complex
199// clusters.
200func (x *GlyphString) IndexToXFull(TextVar string, LengthVar int, AnalysisVar *Analysis, AttrsVar *LogAttr, IndexVar int, TrailingVar bool, XPosVar *int) {
201
202	xGlyphStringIndexToXFull(x.GoPointer(), TextVar, LengthVar, AnalysisVar, AttrsVar, IndexVar, TrailingVar, XPosVar)
203
204}
205
206var xGlyphStringSetSize func(uintptr, int)
207
208// Resize a glyph string to the given length.
209func (x *GlyphString) SetSize(NewLenVar int) {
210
211	xGlyphStringSetSize(x.GoPointer(), NewLenVar)
212
213}
214
215var xGlyphStringXToIndex func(uintptr, string, int, *Analysis, int, *int, *int)
216
217// Convert from x offset to character position.
218//
219// Character positions are computed by dividing up each cluster into
220// equal portions. In scripts where positioning within a cluster is
221// not allowed (such as Thai), the returned value may not be a valid
222// cursor position; the caller must combine the result with the logical
223// attributes for the text to compute the valid cursor position.
224func (x *GlyphString) XToIndex(TextVar string, LengthVar int, AnalysisVar *Analysis, XPosVar int, IndexVar *int, TrailingVar *int) {
225
226	xGlyphStringXToIndex(x.GoPointer(), TextVar, LengthVar, AnalysisVar, XPosVar, IndexVar, TrailingVar)
227
228}
229
230// A `PangoGlyphVisAttr` structure communicates information between
231// the shaping and rendering phases.
232//
233// Currently, it contains cluster start and color information.
234// More attributes may be added in the future.
235//
236// Clusters are stored in visual order, within the cluster, glyphs
237// are always ordered in logical order, since visual order is meaningless;
238// that is, in Arabic text, accent glyphs follow the glyphs for the
239// base character.
240type GlyphVisAttr struct {
241	_ structs.HostLayout
242
243	IsClusterStart uint
244
245	IsColor uint
246}
247
248func (x *GlyphVisAttr) GoPointer() uintptr {
249	return uintptr(unsafe.Pointer(x))
250}
251
252// The `PangoGlyphUnit` type is used to store dimensions within
253// Pango.
254//
255// Dimensions are stored in 1/PANGO_SCALE of a device unit.
256// (A device unit might be a pixel for screen display, or
257// a point on a printer.) PANGO_SCALE is currently 1024, and
258// may change in the future (unlikely though), but you should not
259// depend on its exact value.
260//
261// The PANGO_PIXELS() macro can be used to convert from glyph units
262// into device units with correct rounding.
263type GlyphUnit = int32
264
265// Flags influencing the shaping process.
266//
267// `PangoShapeFlags` can be passed to [func@Pango.shape_with_flags].
268type ShapeFlags int
269
270var xShapeFlagsGLibType func() types.GType
271
272func ShapeFlagsGLibType() types.GType {
273	return xShapeFlagsGLibType()
274}
275
276const (
277
278	// Default value
279	ShapeNoneValue ShapeFlags = 0
280	// Round glyph positions and widths to whole device units
281	//   This option should be set if the target renderer can't do subpixel positioning of glyphs
282	ShapeRoundPositionsValue ShapeFlags = 1
283)
284
285var xShape func(string, int, *Analysis, *GlyphString)
286
287// Convert the characters in @text into glyphs.
288//
289// Given a segment of text and the corresponding `PangoAnalysis` structure
290// returned from [func@Pango.itemize], convert the characters into glyphs. You
291// may also pass in only a substring of the item from [func@Pango.itemize].
292//
293// It is recommended that you use [func@Pango.shape_full] instead, since
294// that API allows for shaping interaction happening across text item
295// boundaries.
296//
297// Some aspects of hyphen insertion and text transformation (in particular,
298// capitalization) require log attrs, and thus can only be handled by
299// [func@Pango.shape_item].
300//
301// Note that the extra attributes in the @analyis that is returned from
302// [func@Pango.itemize] have indices that are relative to the entire paragraph,
303// so you need to subtract the item offset from their indices before
304// calling [func@Pango.shape].
305func Shape(TextVar string, LengthVar int, AnalysisVar *Analysis, GlyphsVar *GlyphString) {
306
307	xShape(TextVar, LengthVar, AnalysisVar, GlyphsVar)
308
309}
310
311var xShapeFull func(string, int, uintptr, int, *Analysis, *GlyphString)
312
313// Convert the characters in @text into glyphs.
314//
315// Given a segment of text and the corresponding `PangoAnalysis` structure
316// returned from [func@Pango.itemize], convert the characters into glyphs.
317// You may also pass in only a substring of the item from [func@Pango.itemize].
318//
319// This is similar to [func@Pango.shape], except it also can optionally take
320// the full paragraph text as input, which will then be used to perform
321// certain cross-item shaping interactions. If you have access to the broader
322// text of which @item_text is part of, provide the broader text as
323// @paragraph_text. If @paragraph_text is %NULL, item text is used instead.
324//
325// Some aspects of hyphen insertion and text transformation (in particular,
326// capitalization) require log attrs, and thus can only be handled by
327// [func@Pango.shape_item].
328//
329// Note that the extra attributes in the @analyis that is returned from
330// [func@Pango.itemize] have indices that are relative to the entire paragraph,
331// so you do not pass the full paragraph text as @paragraph_text, you need
332// to subtract the item offset from their indices before calling
333// [func@Pango.shape_full].
334func ShapeFull(ItemTextVar string, ItemLengthVar int, ParagraphTextVar *string, ParagraphLengthVar int, AnalysisVar *Analysis, GlyphsVar *GlyphString) {
335
336	ParagraphTextVarPtr := core.GStrdupNullable(ParagraphTextVar)
337	defer core.GFreeNullable(ParagraphTextVarPtr)
338
339	xShapeFull(ItemTextVar, ItemLengthVar, ParagraphTextVarPtr, ParagraphLengthVar, AnalysisVar, GlyphsVar)
340
341}
342
343var xShapeItem func(*Item, uintptr, int, *LogAttr, *GlyphString, ShapeFlags)
344
345// Convert the characters in @item into glyphs.
346//
347// This is similar to [func@Pango.shape_with_flags], except it takes a
348// `PangoItem` instead of separate @item_text and @analysis arguments.
349//
350// It also takes @log_attrs, which are needed for implementing some aspects
351// of hyphen insertion and text transforms (in particular, capitalization).
352//
353// Note that the extra attributes in the @analyis that is returned from
354// [func@Pango.itemize] have indices that are relative to the entire paragraph,
355// so you do not pass the full paragraph text as @paragraph_text, you need
356// to subtract the item offset from their indices before calling
357// [func@Pango.shape_with_flags].
358func ShapeItem(ItemVar *Item, ParagraphTextVar *string, ParagraphLengthVar int, LogAttrsVar *LogAttr, GlyphsVar *GlyphString, FlagsVar ShapeFlags) {
359
360	ParagraphTextVarPtr := core.GStrdupNullable(ParagraphTextVar)
361	defer core.GFreeNullable(ParagraphTextVarPtr)
362
363	xShapeItem(ItemVar, ParagraphTextVarPtr, ParagraphLengthVar, LogAttrsVar, GlyphsVar, FlagsVar)
364
365}
366
367var xShapeWithFlags func(string, int, uintptr, int, *Analysis, *GlyphString, ShapeFlags)
368
369// Convert the characters in @text into glyphs.
370//
371// Given a segment of text and the corresponding `PangoAnalysis` structure
372// returned from [func@Pango.itemize], convert the characters into glyphs.
373// You may also pass in only a substring of the item from [func@Pango.itemize].
374//
375// This is similar to [func@Pango.shape_full], except it also takes flags
376// that can influence the shaping process.
377//
378// Some aspects of hyphen insertion and text transformation (in particular,
379// capitalization) require log attrs, and thus can only be handled by
380// [func@Pango.shape_item].
381//
382// Note that the extra attributes in the @analyis that is returned from
383// [func@Pango.itemize] have indices that are relative to the entire paragraph,
384// so you do not pass the full paragraph text as @paragraph_text, you need
385// to subtract the item offset from their indices before calling
386// [func@Pango.shape_with_flags].
387func ShapeWithFlags(ItemTextVar string, ItemLengthVar int, ParagraphTextVar *string, ParagraphLengthVar int, AnalysisVar *Analysis, GlyphsVar *GlyphString, FlagsVar ShapeFlags) {
388
389	ParagraphTextVarPtr := core.GStrdupNullable(ParagraphTextVar)
390	defer core.GFreeNullable(ParagraphTextVarPtr)
391
392	xShapeWithFlags(ItemTextVar, ItemLengthVar, ParagraphTextVarPtr, ParagraphLengthVar, AnalysisVar, GlyphsVar, FlagsVar)
393
394}
395
396func init() {
397	core.SetPackageName("PANGO", "pango")
398	core.SetSharedLibraries("PANGO", []string{"libpango-1.0.so.0"})
399	var libs []uintptr
400	for _, libPath := range core.GetPaths("PANGO") {
401		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
402		if err != nil {
403			panic(err)
404		}
405		libs = append(libs, lib)
406	}
407
408	core.PuregoSafeRegister(&xShapeFlagsGLibType, libs, "pango_shape_flags_get_type")
409
410	core.PuregoSafeRegister(&xShape, libs, "pango_shape")
411	core.PuregoSafeRegister(&xShapeFull, libs, "pango_shape_full")
412	core.PuregoSafeRegister(&xShapeItem, libs, "pango_shape_item")
413	core.PuregoSafeRegister(&xShapeWithFlags, libs, "pango_shape_with_flags")
414
415	core.PuregoSafeRegister(&xGlyphStringGLibType, libs, "pango_glyph_string_get_type")
416
417	core.PuregoSafeRegister(&xNewGlyphString, libs, "pango_glyph_string_new")
418
419	core.PuregoSafeRegister(&xGlyphStringCopy, libs, "pango_glyph_string_copy")
420	core.PuregoSafeRegister(&xGlyphStringExtents, libs, "pango_glyph_string_extents")
421	core.PuregoSafeRegister(&xGlyphStringExtentsRange, libs, "pango_glyph_string_extents_range")
422	core.PuregoSafeRegister(&xGlyphStringFree, libs, "pango_glyph_string_free")
423	core.PuregoSafeRegister(&xGlyphStringGetLogicalWidths, libs, "pango_glyph_string_get_logical_widths")
424	core.PuregoSafeRegister(&xGlyphStringGetWidth, libs, "pango_glyph_string_get_width")
425	core.PuregoSafeRegister(&xGlyphStringIndexToX, libs, "pango_glyph_string_index_to_x")
426	core.PuregoSafeRegister(&xGlyphStringIndexToXFull, libs, "pango_glyph_string_index_to_x_full")
427	core.PuregoSafeRegister(&xGlyphStringSetSize, libs, "pango_glyph_string_set_size")
428	core.PuregoSafeRegister(&xGlyphStringXToIndex, libs, "pango_glyph_string_x_to_index")
429
430}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close