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 public  import gtkc.pangotypes;
32 private import pango.PgAttributeIterator;
33 private import pango.PgAttributeList;
34 private import pango.PgFont;
35 private import pango.PgFontDescription;
36 private import pango.PgFontFamily;
37 private import pango.PgFontMap;
38 private import pango.PgFontMetrics;
39 private import pango.PgFontset;
40 private import pango.PgGlyphString;
41 private import pango.PgItem;
42 private import pango.PgLanguage;
43 private import pango.PgMatrix;
44 private import pango.c.functions;
45 public  import pango.c.types;
46 
47 
48 /**
49  * The #PangoContext structure stores global information
50  * used to control the itemization process.
51  */
52 public class PgContext : ObjectG
53 {
54 	/** the main Gtk struct */
55 	protected PangoContext* pangoContext;
56 
57 	/** Get the main Gtk struct */
58 	public PangoContext* getPgContextStruct(bool transferOwnership = false)
59 	{
60 		if (transferOwnership)
61 			ownedRef = false;
62 		return pangoContext;
63 	}
64 
65 	/** the main Gtk struct as a void* */
66 	protected override void* getStruct()
67 	{
68 		return cast(void*)pangoContext;
69 	}
70 
71 	protected override void setStruct(GObject* obj)
72 	{
73 		pangoContext = cast(PangoContext*)obj;
74 		super.setStruct(obj);
75 	}
76 
77 	/**
78 	 * Sets our main struct and passes it to the parent class.
79 	 */
80 	public this (PangoContext* pangoContext, bool ownedRef = false)
81 	{
82 		this.pangoContext = pangoContext;
83 		super(cast(GObject*)pangoContext, ownedRef);
84 	}
85 
86 
87 	/** */
88 	public static GType getType()
89 	{
90 		return pango_context_get_type();
91 	}
92 
93 	/**
94 	 * Creates a new #PangoContext initialized to default values.
95 	 *
96 	 * This function is not particularly useful as it should always
97 	 * be followed by a pango_context_set_font_map() call, and the
98 	 * function pango_font_map_create_context() does these two steps
99 	 * together and hence users are recommended to use that.
100 	 *
101 	 * If you are using Pango as part of a higher-level system,
102 	 * that system may have it's own way of create a #PangoContext.
103 	 * For instance, the GTK+ toolkit has, among others,
104 	 * gdk_pango_context_get_for_screen(), and
105 	 * gtk_widget_get_pango_context().  Use those instead.
106 	 *
107 	 * Returns: the newly allocated #PangoContext, which should
108 	 *     be freed with g_object_unref().
109 	 *
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this()
113 	{
114 		auto p = pango_context_new();
115 
116 		if(p is null)
117 		{
118 			throw new ConstructionException("null returned by new");
119 		}
120 
121 		this(cast(PangoContext*) p, true);
122 	}
123 
124 	/**
125 	 * Forces a change in the context, which will cause any #PangoLayout
126 	 * using this context to re-layout.
127 	 *
128 	 * This function is only useful when implementing a new backend
129 	 * for Pango, something applications won't do. Backends should
130 	 * call this function if they have attached extra data to the context
131 	 * and such data is changed.
132 	 *
133 	 * Since: 1.32.4
134 	 */
135 	public void changed()
136 	{
137 		pango_context_changed(pangoContext);
138 	}
139 
140 	/**
141 	 * Retrieves the base direction for the context. See
142 	 * pango_context_set_base_dir().
143 	 *
144 	 * Returns: the base direction for the context.
145 	 */
146 	public PangoDirection getBaseDir()
147 	{
148 		return pango_context_get_base_dir(pangoContext);
149 	}
150 
151 	/**
152 	 * Retrieves the base gravity for the context. See
153 	 * 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. This is similar to
204 	 * pango_context_get_base_gravity(), except for when the base gravity
205 	 * is %PANGO_GRAVITY_AUTO for which pango_gravity_get_for_matrix() is used
206 	 * to return the gravity from the current context matrix.
207 	 *
208 	 * Returns: the resolved gravity for the context.
209 	 *
210 	 * Since: 1.16
211 	 */
212 	public PangoGravity getGravity()
213 	{
214 		return pango_context_get_gravity(pangoContext);
215 	}
216 
217 	/**
218 	 * Retrieves the gravity hint for the context. See
219 	 * pango_context_set_gravity_hint() for details.
220 	 *
221 	 * Returns: the gravity hint for the context.
222 	 *
223 	 * Since: 1.16
224 	 */
225 	public PangoGravityHint getGravityHint()
226 	{
227 		return pango_context_get_gravity_hint(pangoContext);
228 	}
229 
230 	/**
231 	 * Retrieves the global language tag for the context.
232 	 *
233 	 * Returns: the global language tag.
234 	 */
235 	public PgLanguage getLanguage()
236 	{
237 		auto p = pango_context_get_language(pangoContext);
238 
239 		if(p is null)
240 		{
241 			return null;
242 		}
243 
244 		return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) p, true);
245 	}
246 
247 	/**
248 	 * Gets the transformation matrix that will be applied when
249 	 * rendering with this context. See pango_context_set_matrix().
250 	 *
251 	 * Returns: the matrix, or %NULL if no matrix has
252 	 *     been set (which is the same as the identity matrix). The returned
253 	 *     matrix is owned by Pango and must not be modified or freed.
254 	 *
255 	 * Since: 1.6
256 	 */
257 	public PgMatrix getMatrix()
258 	{
259 		auto p = pango_context_get_matrix(pangoContext);
260 
261 		if(p is null)
262 		{
263 			return null;
264 		}
265 
266 		return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) p);
267 	}
268 
269 	/**
270 	 * Get overall metric information for a particular font
271 	 * description.  Since the metrics may be substantially different for
272 	 * different scripts, a language tag can be provided to indicate that
273 	 * the metrics should be retrieved that correspond to the script(s)
274 	 * used by that language.
275 	 *
276 	 * The #PangoFontDescription is interpreted in the same way as
277 	 * by pango_itemize(), and the family name may be a comma separated
278 	 * list of figures. If characters from multiple of these families
279 	 * would be used to render the string, then the returned fonts would
280 	 * be a composite of the metrics for the fonts loaded for the
281 	 * individual families.
282 	 *
283 	 * Params:
284 	 *     desc = a #PangoFontDescription structure.  %NULL means that the
285 	 *         font description from the context will be used.
286 	 *     language = language tag used to determine which script to get
287 	 *         the metrics for. %NULL means that the language tag from the context
288 	 *         will be used. If no language tag is set on the context, metrics
289 	 *         for the default language (as determined by pango_language_get_default())
290 	 *         will be returned.
291 	 *
292 	 * Returns: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
293 	 *     when finished using the object.
294 	 */
295 	public PgFontMetrics getMetrics(PgFontDescription desc, PgLanguage language)
296 	{
297 		auto p = pango_context_get_metrics(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct());
298 
299 		if(p is null)
300 		{
301 			return null;
302 		}
303 
304 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true);
305 	}
306 
307 	/**
308 	 * Returns the current serial number of @context.  The serial number is
309 	 * initialized to an small number larger than zero when a new context
310 	 * is created and is increased whenever the context is changed using any
311 	 * of the setter functions, or the #PangoFontMap it uses to find fonts has
312 	 * changed. The serial may wrap, but will never have the value 0. Since it
313 	 * can wrap, never compare it with "less than", always use "not equals".
314 	 *
315 	 * This can be used to automatically detect changes to a #PangoContext, and
316 	 * is only useful when implementing objects that need update when their
317 	 * #PangoContext changes, like #PangoLayout.
318 	 *
319 	 * Returns: The current serial number of @context.
320 	 *
321 	 * Since: 1.32.4
322 	 */
323 	public uint getSerial()
324 	{
325 		return pango_context_get_serial(pangoContext);
326 	}
327 
328 	/**
329 	 * List all families for a context.
330 	 *
331 	 * Params:
332 	 *     families = location to store a pointer to
333 	 *         an array of #PangoFontFamily *. This array should be freed
334 	 *         with g_free().
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 	 * Returns: the newly allocated #PangoFont
358 	 *     that 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 	 * Returns: the newly allocated
381 	 *     #PangoFontset loaded, 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 	 * Returns: 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 	 */
533 	public static void pangoBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr[] attrs)
534 	{
535 		pango_break(Str.toStringz(text), length, analysis, attrs.ptr, cast(int)attrs.length);
536 	}
537 
538 	/**
539 	 * This is the default break algorithm, used if no language
540 	 * engine overrides it. Normally you should use pango_break()
541 	 * instead. Unlike pango_break(),
542 	 * @analysis can be %NULL, but only do that if you know what
543 	 * you're doing. If you need an analysis to pass to pango_break(),
544 	 * you need to pango_itemize().  In most cases however you should
545 	 * simply use pango_get_log_attrs().
546 	 *
547 	 * Params:
548 	 *     text = text to break
549 	 *     length = length of text in bytes (may be -1 if @text is nul-terminated)
550 	 *     analysis = a #PangoAnalysis for the @text
551 	 *     attrs = logical attributes to fill in
552 	 *     attrsLen = size of the array passed as @attrs
553 	 */
554 	public static void defaultBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr* attrs, int attrsLen)
555 	{
556 		pango_default_break(Str.toStringz(text), length, analysis, attrs, attrsLen);
557 	}
558 
559 	/**
560 	 * Searches a string the first character that has a strong
561 	 * direction, according to the Unicode bidirectional algorithm.
562 	 *
563 	 * Params:
564 	 *     text = the text to process
565 	 *     length = length of @text in bytes (may be -1 if @text is nul-terminated)
566 	 *
567 	 * Returns: The direction corresponding to the first strong character.
568 	 *     If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned.
569 	 *
570 	 * Since: 1.4
571 	 */
572 	public static PangoDirection findBaseDir(string text, int length)
573 	{
574 		return pango_find_base_dir(Str.toStringz(text), length);
575 	}
576 
577 	/**
578 	 * Locates a paragraph boundary in @text. A boundary is caused by
579 	 * delimiter characters, such as a newline, carriage return, carriage
580 	 * return-newline pair, or Unicode paragraph separator character.  The
581 	 * index of the run of delimiters is returned in
582 	 * @paragraph_delimiter_index. The index of the start of the paragraph
583 	 * (index after all delimiters) is stored in @next_paragraph_start.
584 	 *
585 	 * If no delimiters are found, both @paragraph_delimiter_index and
586 	 * @next_paragraph_start are filled with the length of @text (an index one
587 	 * off the end).
588 	 *
589 	 * Params:
590 	 *     text = UTF-8 text
591 	 *     length = length of @text in bytes, or -1 if nul-terminated
592 	 *     paragraphDelimiterIndex = return location for index of
593 	 *         delimiter
594 	 *     nextParagraphStart = return location for start of next
595 	 *         paragraph
596 	 */
597 	public static void findParagraphBoundary(string text, int length, out int paragraphDelimiterIndex, out int nextParagraphStart)
598 	{
599 		pango_find_paragraph_boundary(Str.toStringz(text), length, &paragraphDelimiterIndex, &nextParagraphStart);
600 	}
601 
602 	/**
603 	 * Computes a #PangoLogAttr for each character in @text. The @log_attrs
604 	 * array must have one #PangoLogAttr for each position in @text; if
605 	 * @text contains N characters, it has N+1 positions, including the
606 	 * last position at the end of the text. @text should be an entire
607 	 * paragraph; logical attributes can't be computed without context
608 	 * (for example you need to see spaces on either side of a word to know
609 	 * the word is a word).
610 	 *
611 	 * Params:
612 	 *     text = text to process
613 	 *     length = length in bytes of @text
614 	 *     level = embedding level, or -1 if unknown
615 	 *     language = language tag
616 	 *     logAttrs = array with one #PangoLogAttr
617 	 *         per character in @text, plus one extra, to be filled in
618 	 */
619 	public static void getLogAttrs(string text, int length, int level, PgLanguage language, PangoLogAttr[] logAttrs)
620 	{
621 		pango_get_log_attrs(Str.toStringz(text), length, level, (language is null) ? null : language.getPgLanguageStruct(), logAttrs.ptr, cast(int)logAttrs.length);
622 	}
623 
624 	/**
625 	 * If @ch has the Unicode mirrored property and there is another Unicode
626 	 * character that typically has a glyph that is the mirror image of @ch's
627 	 * glyph, puts that character in the address pointed to by @mirrored_ch.
628 	 *
629 	 * Use g_unichar_get_mirror_char() instead; the docs for that function
630 	 * provide full details.
631 	 *
632 	 * Params:
633 	 *     ch = a Unicode character
634 	 *     mirroredCh = location to store the mirrored character
635 	 *
636 	 * Returns: %TRUE if @ch has a mirrored character and @mirrored_ch is
637 	 *     filled in, %FALSE otherwise
638 	 */
639 	public static bool getMirrorChar(dchar ch, dchar* mirroredCh)
640 	{
641 		return pango_get_mirror_char(ch, mirroredCh) != 0;
642 	}
643 
644 	/**
645 	 * Breaks a piece of text into segments with consistent
646 	 * directional level and shaping engine. Each byte of @text will
647 	 * be contained in exactly one of the items in the returned list;
648 	 * the generated list of items will be in logical order (the start
649 	 * offsets of the items are ascending).
650 	 *
651 	 * @cached_iter should be an iterator over @attrs currently positioned at a
652 	 * range before or containing @start_index; @cached_iter will be advanced to
653 	 * the range covering the position just after @start_index + @length.
654 	 * (i.e. if itemizing in a loop, just keep passing in the same @cached_iter).
655 	 *
656 	 * Params:
657 	 *     context = a structure holding information that affects
658 	 *         the itemization process.
659 	 *     text = the text to itemize.
660 	 *     startIndex = first byte in @text to process
661 	 *     length = the number of bytes (not characters) to process
662 	 *         after @start_index.
663 	 *         This must be >= 0.
664 	 *     attrs = the set of attributes that apply to @text.
665 	 *     cachedIter = Cached attribute iterator, or %NULL
666 	 *
667 	 * Returns: a #GList of #PangoItem
668 	 *     structures. The items should be freed using pango_item_free()
669 	 *     probably in combination with g_list_foreach(), and the list itself
670 	 *     using g_list_free().
671 	 */
672 	public static ListG itemize(PgContext context, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter)
673 	{
674 		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());
675 
676 		if(p is null)
677 		{
678 			return null;
679 		}
680 
681 		return new ListG(cast(GList*) p, true);
682 	}
683 
684 	/**
685 	 * Like pango_itemize(), but the base direction to use when
686 	 * computing bidirectional levels (see pango_context_set_base_dir ()),
687 	 * is specified explicitly rather than gotten from the #PangoContext.
688 	 *
689 	 * Params:
690 	 *     context = a structure holding information that affects
691 	 *         the itemization process.
692 	 *     baseDir = base direction to use for bidirectional processing
693 	 *     text = the text to itemize.
694 	 *     startIndex = first byte in @text to process
695 	 *     length = the number of bytes (not characters) to process
696 	 *         after @start_index. This must be >= 0.
697 	 *     attrs = the set of attributes that apply to @text.
698 	 *     cachedIter = Cached attribute iterator, or %NULL
699 	 *
700 	 * Returns: a #GList of
701 	 *     #PangoItem structures.  The items should be freed using
702 	 *     pango_item_free() probably in combination with
703 	 *     g_list_foreach(), and the list itself using g_list_free().
704 	 *
705 	 * Since: 1.4
706 	 */
707 	public static ListG itemizeWithBaseDir(PgContext context, PangoDirection baseDir, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter)
708 	{
709 		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());
710 
711 		if(p is null)
712 		{
713 			return null;
714 		}
715 
716 		return new ListG(cast(GList*) p, true);
717 	}
718 
719 	/**
720 	 * From a list of items in logical order and the associated
721 	 * directional levels, produce a list in visual order.
722 	 * The original list is unmodified.
723 	 *
724 	 * Params:
725 	 *     logicalItems = a #GList of #PangoItem in logical order.
726 	 *
727 	 * Returns: a #GList
728 	 *     of #PangoItem structures in visual order.
729 	 *
730 	 *     (Please open a bug if you use this function.
731 	 *     It is not a particularly convenient interface, and the code
732 	 *     is duplicated elsewhere in Pango for that reason.)
733 	 */
734 	public static ListG reorderItems(ListG logicalItems)
735 	{
736 		auto p = pango_reorder_items((logicalItems is null) ? null : logicalItems.getListGStruct());
737 
738 		if(p is null)
739 		{
740 			return null;
741 		}
742 
743 		return new ListG(cast(GList*) p, true);
744 	}
745 
746 	/**
747 	 * Given a segment of text and the corresponding
748 	 * #PangoAnalysis structure returned from pango_itemize(),
749 	 * convert the characters into glyphs. You may also pass
750 	 * in only a substring of the item from pango_itemize().
751 	 *
752 	 * It is recommended that you use pango_shape_full() instead, since
753 	 * that API allows for shaping interaction happening across text item
754 	 * boundaries.
755 	 *
756 	 * Params:
757 	 *     text = the text to process
758 	 *     length = the length (in bytes) of @text
759 	 *     analysis = #PangoAnalysis structure from pango_itemize()
760 	 *     glyphs = glyph string in which to store results
761 	 */
762 	public static void shape(string text, int length, PangoAnalysis* analysis, PgGlyphString glyphs)
763 	{
764 		pango_shape(Str.toStringz(text), length, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
765 	}
766 
767 	/**
768 	 * Given a segment of text and the corresponding
769 	 * #PangoAnalysis structure returned from pango_itemize(),
770 	 * convert the characters into glyphs. You may also pass
771 	 * in only a substring of the item from pango_itemize().
772 	 *
773 	 * This is similar to pango_shape(), except it also can optionally take
774 	 * the full paragraph text as input, which will then be used to perform
775 	 * certain cross-item shaping interactions.  If you have access to the broader
776 	 * text of which @item_text is part of, provide the broader text as
777 	 * @paragraph_text.  If @paragraph_text is %NULL, item text is used instead.
778 	 *
779 	 * Params:
780 	 *     itemText = valid UTF-8 text to shape.
781 	 *     itemLength = the length (in bytes) of @item_text. -1 means nul-terminated text.
782 	 *     paragraphText = text of the paragraph (see details).  May be %NULL.
783 	 *     paragraphLength = the length (in bytes) of @paragraph_text. -1 means nul-terminated text.
784 	 *     analysis = #PangoAnalysis structure from pango_itemize().
785 	 *     glyphs = glyph string in which to store results.
786 	 *
787 	 * Since: 1.32
788 	 */
789 	public static void shapeFull(string itemText, int itemLength, string paragraphText, int paragraphLength, PangoAnalysis* analysis, PgGlyphString glyphs)
790 	{
791 		pango_shape_full(Str.toStringz(itemText), itemLength, Str.toStringz(paragraphText), paragraphLength, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct());
792 	}
793 
794 	/**
795 	 * Determines the inherent direction of a character; either
796 	 * %PANGO_DIRECTION_LTR, %PANGO_DIRECTION_RTL, or
797 	 * %PANGO_DIRECTION_NEUTRAL.
798 	 *
799 	 * This function is useful to categorize characters into left-to-right
800 	 * letters, right-to-left letters, and everything else.  If full
801 	 * Unicode bidirectional type of a character is needed,
802 	 * pango_bidi_type_for_unichar() can be used instead.
803 	 *
804 	 * Params:
805 	 *     ch = a Unicode character
806 	 *
807 	 * Returns: the direction of the character.
808 	 */
809 	public static PangoDirection unicharDirection(dchar ch)
810 	{
811 		return pango_unichar_direction(ch);
812 	}
813 }