1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module pango.PgContext;
26 
27 private import glib.ConstructionException;
28 private import glib.ListG;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import pango.PgAttributeIterator;
32 private import pango.PgAttributeList;
33 private import pango.PgFont;
34 private import pango.PgFontDescription;
35 private import pango.PgFontFamily;
36 private import pango.PgFontMap;
37 private import pango.PgFontMetrics;
38 private import pango.PgFontset;
39 private import pango.PgGlyphString;
40 private import pango.PgItem;
41 private import pango.PgLanguage;
42 private import pango.PgMatrix;
43 private import pango.c.functions;
44 public  import pango.c.types;
45 
46 
47 /**
48  * A `PangoContext` stores global information used to control the
49  * itemization process.
50  * 
51  * The information stored by `PangoContext includes the fontmap used
52  * to look up fonts, and default values such as the default language,
53  * default gravity, or default font.
54  * 
55  * To obtain a `PangoContext`, use [method@Pango.FontMap.create_context].
56  */
57 public class PgContext : ObjectG
58 {
59 	/** the main Gtk struct */
60 	protected PangoContext* pangoContext;
61 
62 	/** Get the main Gtk struct */
63 	public PangoContext* getPgContextStruct(bool transferOwnership = false)
64 	{
65 		if (transferOwnership)
66 			ownedRef = false;
67 		return pangoContext;
68 	}
69 
70 	/** the main Gtk struct as a void* */
71 	protected override void* getStruct()
72 	{
73 		return cast(void*)pangoContext;
74 	}
75 
76 	/**
77 	 * Sets our main struct and passes it to the parent class.
78 	 */
79 	public this (PangoContext* pangoContext, bool ownedRef = false)
80 	{
81 		this.pangoContext = pangoContext;
82 		super(cast(GObject*)pangoContext, ownedRef);
83 	}
84 
85 
86 	/** */
87 	public static GType getType()
88 	{
89 		return pango_context_get_type();
90 	}
91 
92 	/**
93 	 * Creates a new `PangoContext` initialized to default values.
94 	 *
95 	 * This function is not particularly useful as it should always
96 	 * be followed by a [method@Pango.Context.set_font_map] call, and the
97 	 * function [method@Pango.FontMap.create_context] does these two steps
98 	 * together and hence users are recommended to use that.
99 	 *
100 	 * If you are using Pango as part of a higher-level system,
101 	 * that system may have it's own way of create a `PangoContext`.
102 	 * For instance, the GTK toolkit has, among others,
103 	 * `gtk_widget_get_pango_context()`. Use those instead.
104 	 *
105 	 * Returns: the newly allocated `PangoContext`, which should
106 	 *     be freed with g_object_unref().
107 	 *
108 	 * Throws: ConstructionException GTK+ fails to create the object.
109 	 */
110 	public this()
111 	{
112 		auto __p = pango_context_new();
113 
114 		if(__p is null)
115 		{
116 			throw new ConstructionException("null returned by new");
117 		}
118 
119 		this(cast(PangoContext*) __p, true);
120 	}
121 
122 	/**
123 	 * Forces a change in the context, which will cause any `PangoLayout`
124 	 * using this context to re-layout.
125 	 *
126 	 * This function is only useful when implementing a new backend
127 	 * for Pango, something applications won't do. Backends should
128 	 * call this function if they have attached extra data to the context
129 	 * and such data is changed.
130 	 *
131 	 * Since: 1.32.4
132 	 */
133 	public void changed()
134 	{
135 		pango_context_changed(pangoContext);
136 	}
137 
138 	/**
139 	 * Retrieves the base direction for the context.
140 	 *
141 	 * See [method@Pango.Context.set_base_dir].
142 	 *
143 	 * Returns: the base direction for the context.
144 	 */
145 	public PangoDirection getBaseDir()
146 	{
147 		return pango_context_get_base_dir(pangoContext);
148 	}
149 
150 	/**
151 	 * Retrieves the base gravity for the context.
152 	 *
153 	 * See [method@Pango.Context.set_base_gravity].
154 	 *
155 	 * Returns: the base gravity for the context.
156 	 *
157 	 * Since: 1.16
158 	 */
159 	public PangoGravity getBaseGravity()
160 	{
161 		return pango_context_get_base_gravity(pangoContext);
162 	}
163 
164 	/**
165 	 * Retrieve the default font description for the context.
166 	 *
167 	 * Returns: a pointer to the context's default font
168 	 *     description. This value must not be modified or freed.
169 	 */
170 	public PgFontDescription getFontDescription()
171 	{
172 		auto __p = pango_context_get_font_description(pangoContext);
173 
174 		if(__p is null)
175 		{
176 			return null;
177 		}
178 
179 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) __p);
180 	}
181 
182 	/**
183 	 * Gets the `PangoFontMap` used to look up fonts for this context.
184 	 *
185 	 * Returns: the font map for the `PangoContext`.
186 	 *     This value is owned by Pango and should not be unreferenced.
187 	 *
188 	 * Since: 1.6
189 	 */
190 	public PgFontMap getFontMap()
191 	{
192 		auto __p = pango_context_get_font_map(pangoContext);
193 
194 		if(__p is null)
195 		{
196 			return null;
197 		}
198 
199 		return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) __p);
200 	}
201 
202 	/**
203 	 * Retrieves the gravity for the context.
204 	 *
205 	 * This is similar to [method@Pango.Context.get_base_gravity],
206 	 * except for when the base gravity is %PANGO_GRAVITY_AUTO for
207 	 * which [type_func@Pango.Gravity.get_for_matrix] is used to return the
208 	 * gravity from the current context matrix.
209 	 *
210 	 * Returns: the resolved gravity for the context.
211 	 *
212 	 * Since: 1.16
213 	 */
214 	public PangoGravity getGravity()
215 	{
216 		return pango_context_get_gravity(pangoContext);
217 	}
218 
219 	/**
220 	 * Retrieves the gravity hint for the context.
221 	 *
222 	 * See [method@Pango.Context.set_gravity_hint] for details.
223 	 *
224 	 * Returns: the gravity hint for the context.
225 	 *
226 	 * Since: 1.16
227 	 */
228 	public PangoGravityHint getGravityHint()
229 	{
230 		return pango_context_get_gravity_hint(pangoContext);
231 	}
232 
233 	/**
234 	 * Retrieves the global language tag for the context.
235 	 *
236 	 * Returns: the global language tag.
237 	 */
238 	public PgLanguage getLanguage()
239 	{
240 		auto __p = pango_context_get_language(pangoContext);
241 
242 		if(__p is null)
243 		{
244 			return null;
245 		}
246 
247 		return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) __p, true);
248 	}
249 
250 	/**
251 	 * Gets the transformation matrix that will be applied when
252 	 * rendering with this context.
253 	 *
254 	 * See [method@Pango.Context.set_matrix].
255 	 *
256 	 * Returns: the matrix, or %NULL if no matrix has
257 	 *     been set (which is the same as the identity matrix). The returned
258 	 *     matrix is owned by Pango and must not be modified or freed.
259 	 *
260 	 * Since: 1.6
261 	 */
262 	public PgMatrix getMatrix()
263 	{
264 		auto __p = pango_context_get_matrix(pangoContext);
265 
266 		if(__p is null)
267 		{
268 			return null;
269 		}
270 
271 		return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) __p);
272 	}
273 
274 	/**
275 	 * Get overall metric information for a particular font description.
276 	 *
277 	 * Since the metrics may be substantially different for different scripts,
278 	 * a language tag can be provided to indicate that the metrics should be
279 	 * retrieved that correspond to the script(s) used by that language.
280 	 *
281 	 * The `PangoFontDescription` is interpreted in the same way as by [func@itemize],
282 	 * and the family name may be a comma separated list of names. If characters
283 	 * from multiple of these families would be used to render the string, then
284 	 * the returned fonts would be a composite of the metrics for the fonts loaded
285 	 * for the individual families.
286 	 *
287 	 * Params:
288 	 *     desc = a `PangoFontDescription` structure. %NULL means that the
289 	 *         font description from the context will be used.
290 	 *     language = language tag used to determine which script to get
291 	 *         the metrics for. %NULL means that the language tag from the context
292 	 *         will be used. If no language tag is set on the context, metrics
293 	 *         for the default language (as determined by [type_func@Pango.Language.get_default]
294 	 *         will be returned.
295 	 *
296 	 * Returns: a `PangoFontMetrics` object. The caller must call
297 	 *     [method@Pango.FontMetrics.unref] when finished using the object.
298 	 */
299 	public PgFontMetrics getMetrics(PgFontDescription desc, PgLanguage language)
300 	{
301 		auto __p = pango_context_get_metrics(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct());
302 
303 		if(__p is null)
304 		{
305 			return null;
306 		}
307 
308 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) __p, true);
309 	}
310 
311 	/**
312 	 * Returns whether font rendering with this context should
313 	 * round glyph positions and widths.
314 	 *
315 	 * Since: 1.44
316 	 */
317 	public bool getRoundGlyphPositions()
318 	{
319 		return pango_context_get_round_glyph_positions(pangoContext) != 0;
320 	}
321 
322 	/**
323 	 * Returns the current serial number of @context.
324 	 *
325 	 * The serial number is initialized to an small number larger than zero
326 	 * when a new context is created and is increased whenever the context
327 	 * is changed using any of the setter functions, or the `PangoFontMap` it
328 	 * uses to find fonts has changed. The serial may wrap, but will never
329 	 * have the value 0. Since it can wrap, never compare it with "less than",
330 	 * always use "not equals".
331 	 *
332 	 * This can be used to automatically detect changes to a `PangoContext`,
333 	 * and is only useful when implementing objects that need update when their
334 	 * `PangoContext` changes, like `PangoLayout`.
335 	 *
336 	 * Returns: The current serial number of @context.
337 	 *
338 	 * Since: 1.32.4
339 	 */
340 	public uint getSerial()
341 	{
342 		return pango_context_get_serial(pangoContext);
343 	}
344 
345 	/**
346 	 * List all families for a context.
347 	 *
348 	 * Params:
349 	 *     families = location
350 	 *         to store a pointer to an array of `PangoFontFamily`. This array should
351 	 *         be freed with g_free().
352 	 */
353 	public void listFamilies(out PgFontFamily[] families)
354 	{
355 		PangoFontFamily** outfamilies = null;
356 		int nFamilies;
357 
358 		pango_context_list_families(pangoContext, &outfamilies, &nFamilies);
359 
360 		families = new PgFontFamily[nFamilies];
361 		for(size_t i = 0; i < nFamilies; i++)
362 		{
363 			families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]);
364 		}
365 	}
366 
367 	/**
368 	 * Loads the font in one of the fontmaps in the context
369 	 * that is the closest match for @desc.
370 	 *
371 	 * Params:
372 	 *     desc = a `PangoFontDescription` describing the font to load
373 	 *
374 	 * Returns: the newly allocated `PangoFont`
375 	 *     that was loaded, or %NULL if no font matched.
376 	 */
377 	public PgFont loadFont(PgFontDescription desc)
378 	{
379 		auto __p = pango_context_load_font(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct());
380 
381 		if(__p is null)
382 		{
383 			return null;
384 		}
385 
386 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) __p, true);
387 	}
388 
389 	/**
390 	 * Load a set of fonts in the context that can be used to render
391 	 * a font matching @desc.
392 	 *
393 	 * Params:
394 	 *     desc = a `PangoFontDescription` describing the fonts to load
395 	 *     language = a `PangoLanguage` the fonts will be used for
396 	 *
397 	 * Returns: the newly allocated
398 	 *     `PangoFontset` loaded, or %NULL if no font matched.
399 	 */
400 	public PgFontset loadFontset(PgFontDescription desc, PgLanguage language)
401 	{
402 		auto __p = pango_context_load_fontset(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct());
403 
404 		if(__p is null)
405 		{
406 			return null;
407 		}
408 
409 		return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) __p, true);
410 	}
411 
412 	/**
413 	 * Sets the base direction for the context.
414 	 *
415 	 * The base direction is used in applying the Unicode bidirectional
416 	 * algorithm; if the @direction is %PANGO_DIRECTION_LTR or
417 	 * %PANGO_DIRECTION_RTL, then the value will be used as the paragraph
418 	 * direction in the Unicode bidirectional algorithm. A value of
419 	 * %PANGO_DIRECTION_WEAK_LTR or %PANGO_DIRECTION_WEAK_RTL is used only
420 	 * for paragraphs that do not contain any strong characters themselves.
421 	 *
422 	 * Params:
423 	 *     direction = the new base direction
424 	 */
425 	public void setBaseDir(PangoDirection direction)
426 	{
427 		pango_context_set_base_dir(pangoContext, direction);
428 	}
429 
430 	/**
431 	 * Sets the base gravity for the context.
432 	 *
433 	 * The base gravity is used in laying vertical text out.
434 	 *
435 	 * Params:
436 	 *     gravity = the new base gravity
437 	 *
438 	 * Since: 1.16
439 	 */
440 	public void setBaseGravity(PangoGravity gravity)
441 	{
442 		pango_context_set_base_gravity(pangoContext, gravity);
443 	}
444 
445 	/**
446 	 * Set the default font description for the context
447 	 *
448 	 * Params:
449 	 *     desc = the new pango font description
450 	 */
451 	public void setFontDescription(PgFontDescription desc)
452 	{
453 		pango_context_set_font_description(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct());
454 	}
455 
456 	/**
457 	 * Sets the font map to be searched when fonts are looked-up
458 	 * in this context.
459 	 *
460 	 * This is only for internal use by Pango backends, a `PangoContext`
461 	 * obtained via one of the recommended methods should already have a
462 	 * suitable font map.
463 	 *
464 	 * Params:
465 	 *     fontMap = the `PangoFontMap` to set.
466 	 */
467 	public void setFontMap(PgFontMap fontMap)
468 	{
469 		pango_context_set_font_map(pangoContext, (fontMap is null) ? null : fontMap.getPgFontMapStruct());
470 	}
471 
472 	/**
473 	 * Sets the gravity hint for the context.
474 	 *
475 	 * The gravity hint is used in laying vertical text out, and
476 	 * is only relevant if gravity of the context as returned by
477 	 * [method@Pango.Context.get_gravity] is set to %PANGO_GRAVITY_EAST
478 	 * or %PANGO_GRAVITY_WEST.
479 	 *
480 	 * Params:
481 	 *     hint = the new gravity hint
482 	 *
483 	 * Since: 1.16
484 	 */
485 	public void setGravityHint(PangoGravityHint hint)
486 	{
487 		pango_context_set_gravity_hint(pangoContext, hint);
488 	}
489 
490 	/**
491 	 * Sets the global language tag for the context.
492 	 *
493 	 * The default language for the locale of the running process
494 	 * can be found using [type_func@Pango.Language.get_default].
495 	 *
496 	 * Params:
497 	 *     language = the new language tag.
498 	 */
499 	public void setLanguage(PgLanguage language)
500 	{
501 		pango_context_set_language(pangoContext, (language is null) ? null : language.getPgLanguageStruct());
502 	}
503 
504 	/**
505 	 * Sets the transformation matrix that will be applied when rendering
506 	 * with this context.
507 	 *
508 	 * Note that reported metrics are in the user space coordinates before
509 	 * the application of the matrix, not device-space coordinates after the
510 	 * application of the matrix. So, they don't scale with the matrix, though
511 	 * they may change slightly for different matrices, depending on how the
512 	 * text is fit to the pixel grid.
513 	 *
514 	 * Params:
515 	 *     matrix = a `PangoMatrix`, or %NULL to unset any existing
516 	 *         matrix. (No matrix set is the same as setting the identity matrix.)
517 	 *
518 	 * Since: 1.6
519 	 */
520 	public void setMatrix(PgMatrix matrix)
521 	{
522 		pango_context_set_matrix(pangoContext, (matrix is null) ? null : matrix.getPgMatrixStruct());
523 	}
524 
525 	/**
526 	 * Sets whether font rendering with this context should
527 	 * round glyph positions and widths to integral positions,
528 	 * in device units.
529 	 *
530 	 * This is useful when the renderer can't handle subpixel
531 	 * positioning of glyphs.
532 	 *
533 	 * The default value is to round glyph positions, to remain
534 	 * compatible with previous Pango behavior.
535 	 *
536 	 * Params:
537 	 *     roundPositions = whether to round glyph positions
538 	 *
539 	 * Since: 1.44
540 	 */
541 	public void setRoundGlyphPositions(bool roundPositions)
542 	{
543 		pango_context_set_round_glyph_positions(pangoContext, roundPositions);
544 	}
545 
546 	/**
547 	 * Determines the bidirectional type of a character.
548 	 *
549 	 * The bidirectional type is specified in the Unicode Character Database.
550 	 *
551 	 * A simplified version of this function is available as [func@unichar_direction].
552 	 *
553 	 * Params:
554 	 *     ch = a Unicode character
555 	 *
556 	 * Returns: the bidirectional character type, as used in the
557 	 *     Unicode bidirectional algorithm.
558 	 *
559 	 * Since: 1.22
560 	 */
561 	public static PangoBidiType bidiTypeForUnichar(dchar ch)
562 	{
563 		return pango_bidi_type_for_unichar(ch);
564 	}
565 
566 	/**
567 	 * Determines possible line, word, and character breaks for a string of
568 	 * Unicode text with a single analysis.
569 	 *
570 	 * For most purposes you may want to use pango_get_log_attrs().
571 	 *
572 	 * Deprecated: Use pango_default_break() and pango_tailor_break()
573 	 *
574 	 * Params:
575 	 *     text = the text to process. Must be valid UTF-8
576 	 *     length = length of @text in bytes (may be -1 if @text is nul-terminated)
577 	 *     analysis = #PangoAnalysis structure from pango_itemize()
578 	 *     attrs = an array to store character
579 	 *         information in
580 	 */
581 	public static void pangoBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr[] attrs)
582 	{
583 		pango_break(Str.toStringz(text), length, analysis, attrs.ptr, cast(int)attrs.length);
584 	}
585 
586 	/**
587 	 * This is the default break algorithm.
588 	 *
589 	 * It applies Unicode rules without language-specific tailoring, therefore
590 	 * the @analyis argument is unused and can be %NULL.
591 	 *
592 	 * See pango_tailor_break() for language-specific breaks.
593 	 *
594 	 * Params:
595 	 *     text = text to break. Must be valid UTF-8
596 	 *     length = length of text in bytes (may be -1 if @text is nul-terminated)
597 	 *     analysis = a #PangoAnalysis for the @text
598 	 *     attrs = logical attributes to fill in
599 	 *     attrsLen = size of the array passed as @attrs
600 	 */
601 	public static void defaultBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr* attrs, int attrsLen)
602 	{
603 		pango_default_break(Str.toStringz(text), length, analysis, attrs, attrsLen);
604 	}
605 
606 	/**
607 	 * Searches a string the first character that has a strong
608 	 * direction, according to the Unicode bidirectional algorithm.
609 	 *
610 	 * Params:
611 	 *     text = the text to process. Must be valid UTF-8
612 	 *     length = length of @text in bytes (may be -1 if @text is nul-terminated)
613 	 *
614 	 * Returns: The direction corresponding to the first strong character.
615 	 *     If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned.
616 	 *
617 	 * Since: 1.4
618 	 */
619 	public static PangoDirection findBaseDir(string text, int length)
620 	{
621 		return pango_find_base_dir(Str.toStringz(text), length);
622 	}
623 
624 	/**
625 	 * Locates a paragraph boundary in @text.
626 	 *
627 	 * A boundary is caused by delimiter characters, such as a newline, carriage
628 	 * return, carriage return-newline pair, or Unicode paragraph separator character.
629 	 * The index of the run of delimiters is returned in @paragraph_delimiter_index.
630 	 * The index of the start of the paragrap (index after all delimiters) is stored
631 	 * in @next_paragraph_start.
632 	 *
633 	 * If no delimiters are found, both @paragraph_delimiter_index and
634 	 * @next_paragraph_start are filled with the length of @text (an index one
635 	 * off the end).
636 	 *
637 	 * Params:
638 	 *     text = UTF-8 text
639 	 *     length = length of @text in bytes, or -1 if nul-terminated
640 	 *     paragraphDelimiterIndex = return location for index of
641 	 *         delimiter
642 	 *     nextParagraphStart = return location for start of next
643 	 *         paragraph
644 	 */
645 	public static void findParagraphBoundary(string text, int length, out int paragraphDelimiterIndex, out int nextParagraphStart)
646 	{
647 		pango_find_paragraph_boundary(Str.toStringz(text), length, &paragraphDelimiterIndex, &nextParagraphStart);
648 	}
649 
650 	/**
651 	 * Computes a `PangoLogAttr` for each character in @text.
652 	 *
653 	 * The @log_attrs array must have one `PangoLogAttr` for each position in @text;
654 	 * if @text contains N characters, it has N+1 positions, including the last
655 	 * position at the end of the text. @text should be an entire paragraph; logical
656 	 * attributes can't be computed without context (for example you need to see
657 	 * spaces on either side of a word to know the word is a word).
658 	 *
659 	 * Params:
660 	 *     text = text to process. Must be valid UTF-8
661 	 *     length = length in bytes of @text
662 	 *     level = embedding level, or -1 if unknown
663 	 *     language = language tag
664 	 *     logAttrs = array with one `PangoLogAttr`
665 	 *         per character in @text, plus one extra, to be filled in
666 	 */
667 	public static void getLogAttrs(string text, int length, int level, PgLanguage language, PangoLogAttr[] logAttrs)
668 	{
669 		pango_get_log_attrs(Str.toStringz(text), length, level, (language is null) ? null : language.getPgLanguageStruct(), logAttrs.ptr, cast(int)logAttrs.length);
670 	}
671 
672 	/**
673 	 * Returns the mirrored character of a Unicode character.
674 	 *
675 	 * Mirror characters are determined by the Unicode mirrored property.
676 	 *
677 	 * Deprecated: Use g_unichar_get_mirror_char() instead; the docs for that function
678 	 * provide full details.
679 	 *
680 	 * Params:
681 	 *     ch = a Unicode character
682 	 *     mirroredCh = location to store the mirrored character
683 	 *
684 	 * Returns: %TRUE if @ch has a mirrored character and @mirrored_ch is
685 	 *     filled in, %FALSE otherwise
686 	 */
687 	public static bool getMirrorChar(dchar ch, dchar* mirroredCh)
688 	{
689 		return pango_get_mirror_char(ch, mirroredCh) != 0;
690 	}
691 
692 	/**
693 	 * Breaks a piece of text into segments with consistent directional
694 	 * level and font.
695 	 *
696 	 * Each byte of @text will be contained in exactly one of the items in the
697 	 * returned list; the generated list of items will be in logical order (the
698 	 * start offsets of the items are ascending).
699 	 *
700 	 * @cached_iter should be an iterator over @attrs currently positioned
701 	 * at a range before or containing @start_index; @cached_iter will be
702 	 * advanced to the range covering the position just after
703 	 * @start_index + @length. (i.e. if itemizing in a loop, just keep passing
704 	 * in the same @cached_iter).
705 	 *
706 	 * Params:
707 	 *     context = a structure holding information that affects
708 	 *         the itemization process.
709 	 *     text = the text to itemize. Must be valid UTF-8
710 	 *     startIndex = first byte in @text to process
711 	 *     length = the number of bytes (not characters) to process
712 	 *         after @start_index. This must be >= 0.
713 	 *     attrs = the set of attributes that apply to @text.
714 	 *     cachedIter = Cached attribute iterator, or %NULL
715 	 *
716 	 * Returns: a `GList` of
717 	 *     [struct@Pango.Item] structures. The items should be freed using
718 	 *     [method@Pango.Item.free] probably in combination with g_list_free_full().
719 	 */
720 	public static ListG itemize(PgContext context, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter)
721 	{
722 		auto __p = pango_itemize((context is null) ? null : context.getPgContextStruct(), Str.toStringz(text), startIndex, length, (attrs is null) ? null : attrs.getPgAttributeListStruct(), (cachedIter is null) ? null : cachedIter.getPgAttributeIteratorStruct());
723 
724 		if(__p is null)
725 		{
726 			return null;
727 		}
728 
729 		return new ListG(cast(GList*) __p, true);
730 	}
731 
732 	/**
733 	 * Like `pango_itemize()`, but with an explicitly specified base direction.
734 	 *
735 	 * The base direction is used when computing bidirectional levels.
736 	 * (see [method@Pango.Context.set_base_dir]). [func@itemize] gets the
737 	 * base direction from the `PangoContext`.
738 	 *
739 	 * Params:
740 	 *     context = a structure holding information that affects
741 	 *         the itemization process.
742 	 *     baseDir = base direction to use for bidirectional processing
743 	 *     text = the text to itemize.
744 	 *     startIndex = first byte in @text to process
745 	 *     length = the number of bytes (not characters) to process
746 	 *         after @start_index. This must be >= 0.
747 	 *     attrs = the set of attributes that apply to @text.
748 	 *     cachedIter = Cached attribute iterator, or %NULL
749 	 *
750 	 * Returns: a `GList` of
751 	 *     [struct@Pango.Item] structures. The items should be freed using
752 	 *     [method@Pango.Item.free] probably in combination with g_list_free_full().
753 	 *
754 	 * Since: 1.4
755 	 */
756 	public static ListG itemizeWithBaseDir(PgContext context, PangoDirection baseDir, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter)
757 	{
758 		auto __p = pango_itemize_with_base_dir((context is null) ? null : context.getPgContextStruct(), baseDir, Str.toStringz(text), startIndex, length, (attrs is null) ? null : attrs.getPgAttributeListStruct(), (cachedIter is null) ? null : cachedIter.getPgAttributeIteratorStruct());
759 
760 		if(__p is null)
761 		{
762 			return null;
763 		}
764 
765 		return new ListG(cast(GList*) __p, true);
766 	}
767 
768 	/**
769 	 * Reorder items from logical order to visual order.
770 	 *
771 	 * The visual order is determined from the associated directional
772 	 * levels of the items. The original list is unmodified.
773 	 *
774 	 * Params:
775 	 *     logicalItems = a `GList` of `PangoItem`
776 	 *         in logical order.
777 	 *
778 	 * Returns: a #GList
779 	 *     of #PangoItem structures in visual order.
780 	 *
781 	 *     (Please open a bug if you use this function.
782 	 *     It is not a particularly convenient interface, and the code
783 	 *     is duplicated elsewhere in Pango for that reason.)
784 	 */
785 	public static ListG reorderItems(ListG logicalItems)
786 	{
787 		auto __p = pango_reorder_items((logicalItems is null) ? null : logicalItems.getListGStruct());
788 
789 		if(__p is null)
790 		{
791 			return null;
792 		}
793 
794 		return new ListG(cast(GList*) __p, true);
795 	}
796 
797 	/**
798 	 * Convert the characters in @text into glyphs.
799 	 *
800 	 * Given a segment of text and the corresponding `PangoAnalysis` structure
801 	 * returned from [func@itemize], convert the characters into glyphs. You
802 	 * may also pass in only a substring of the item from [func@itemize].
803 	 *
804 	 * It is recommended that you use [func@shape_full] instead, since
805 	 * that API allows for shaping interaction happening across text item
806 	 * boundaries.
807 	 *
808 	 * Note that the extra attributes in the @analyis that is returned from
809 	 * [func@itemize] have indices that are relative to the entire paragraph,
810 	 * so you need to subtract the item offset from their indices before
811 	 * calling [func@shape].
812 	 *
813 	 * Params:
814 	 *     text = the text to process
815 	 *     length = the length (in bytes) of @text
816 	 *     analysis = `PangoAnalysis` structure from [func@itemize]
817 	 *     glyphs = glyph string in which to store results
818 	 */
819 	public static void shape(string text, int length, PangoAnalysis* analysis, PgGlyphString glyphs)
820 	{
821 		pango_shape(Str.toStringz(text), length, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
822 	}
823 
824 	/**
825 	 * Convert the characters in @text into glyphs.
826 	 *
827 	 * Given a segment of text and the corresponding `PangoAnalysis` structure
828 	 * returned from [func@itemize], convert the characters into glyphs. You may
829 	 * also pass in only a substring of the item from [func@itemize].
830 	 *
831 	 * This is similar to [func@shape], except it also can optionally take
832 	 * the full paragraph text as input, which will then be used to perform
833 	 * certain cross-item shaping interactions. If you have access to the broader
834 	 * text of which @item_text is part of, provide the broader text as
835 	 * @paragraph_text. If @paragraph_text is %NULL, item text is used instead.
836 	 *
837 	 * Note that the extra attributes in the @analyis that is returned from
838 	 * [func@itemize] have indices that are relative to the entire paragraph,
839 	 * so you do not pass the full paragraph text as @paragraph_text, you need
840 	 * to subtract the item offset from their indices before calling [func@shape_full].
841 	 *
842 	 * Params:
843 	 *     itemText = valid UTF-8 text to shape.
844 	 *     itemLength = the length (in bytes) of @item_text. -1 means nul-terminated text.
845 	 *     paragraphText = text of the paragraph (see details).  May be %NULL.
846 	 *     paragraphLength = the length (in bytes) of @paragraph_text. -1 means nul-terminated text.
847 	 *     analysis = `PangoAnalysis` structure from [func@itemize].
848 	 *     glyphs = glyph string in which to store results.
849 	 *
850 	 * Since: 1.32
851 	 */
852 	public static void shapeFull(string itemText, int itemLength, string paragraphText, int paragraphLength, PangoAnalysis* analysis, PgGlyphString glyphs)
853 	{
854 		pango_shape_full(Str.toStringz(itemText), itemLength, Str.toStringz(paragraphText), paragraphLength, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
855 	}
856 
857 	/**
858 	 * Determines the inherent direction of a character.
859 	 *
860 	 * The inherent direction is either %PANGO_DIRECTION_LTR, %PANGO_DIRECTION_RTL,
861 	 * or %PANGO_DIRECTION_NEUTRAL.
862 	 *
863 	 * This function is useful to categorize characters into left-to-right
864 	 * letters, right-to-left letters, and everything else. If full Unicode
865 	 * bidirectional type of a character is needed,
866 	 * [type_func@Pango.BidiType.for_unichar] can be used instead.
867 	 *
868 	 * Params:
869 	 *     ch = a Unicode character
870 	 *
871 	 * Returns: the direction of the character.
872 	 */
873 	public static PangoDirection unicharDirection(dchar ch)
874 	{
875 		return pango_unichar_direction(ch);
876 	}
877 }