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