I've no idea here...
[gtkD.git] / src / pango / PgContext.d
blob0b3249b73ac6d905db2b43ac852873d18ac2aa28
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = pango-Text-Processing.html
26 * outPack = pango
27 * outFile = PgContext
28 * strct = PangoContext
29 * realStrct=
30 * ctorStrct=
31 * clss = PgContext
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - pango_context_
40 * omit structs:
41 * omit prefixes:
42 * - pango_item_
43 * omit code:
44 * imports:
45 * - glib.ListSG
46 * - glib.ListG
47 * - pango.PgItem
48 * - pango.PgLayout
49 * - pango.PgFontDescription
50 * - pango.PgFontMetrics
51 * - pango.PgFontFamily
52 * - pango.PgFontFace
53 * - pango.PgFontMap
54 * - pango.PgFontsetSimple
55 * - pango.PgAttribute
56 * - pango.PgAttributeList
57 * - pango.PgLanguage
58 * - pango.PgTabArray
59 * - pango.PgLayout
60 * - pango.PgLayoutIter
61 * - pango.PgScriptIter
62 * - glib.Str
63 * structWrap:
64 * - GList* -> ListG
65 * - GSList* -> ListSG
66 * - PangoAttribute* -> PgAttribute
67 * - PangoAttributeList* -> PgAttributeList
68 * - PangoFontDescription* -> PgFontDescription
69 * - PangoFontFace* -> PgFontFace
70 * - PangoFontFamily* -> PgFontFamily
71 * - PangoFontMap* -> PgFontMap
72 * - PangoFontMetrics* -> PgFontMetrics
73 * - PangoFontsetSimple* -> PgFontsetSimple
74 * - PangoItem* -> PgItem
75 * - PangoLanguage* -> PgLanguage
76 * - PangoLayout* -> PgLayout
77 * - PangoLayoutIter* -> PgLayoutIter
78 * - PangoScriptIter* -> PgScriptIter
79 * - PangoTabArray* -> PgTabArray
80 * local aliases:
83 module pango.PgContext;
85 private import pango.pangotypes;
87 private import lib.pango;
89 private import glib.ListSG;
90 private import glib.ListG;
91 private import pango.PgItem;
92 private import pango.PgLayout;
93 private import pango.PgFontDescription;
94 private import pango.PgFontMetrics;
95 private import pango.PgFontFamily;
96 private import pango.PgFontFace;
97 private import pango.PgFontMap;
98 private import pango.PgFontsetSimple;
99 private import pango.PgAttribute;
100 private import pango.PgAttributeList;
101 private import pango.PgLanguage;
102 private import pango.PgTabArray;
103 private import pango.PgLayout;
104 private import pango.PgLayoutIter;
105 private import pango.PgScriptIter;
106 private import glib.Str;
109 * Description
110 * The Pango rendering pipeline takes a string of
111 * Unicode characters and converts it into glyphs.
112 * The functions described in this section accomplish
113 * various steps of this process.
115 private import gobject.ObjectG;
116 public class PgContext : ObjectG
119 /** the main Gtk struct */
120 protected PangoContext* pangoContext;
123 public PangoContext* getPgContextStruct()
125 return pangoContext;
129 /** the main Gtk struct as a void* */
130 protected void* getStruct()
132 return cast(void*)pangoContext;
136 * Sets our main struct and passes it to the parent class
138 public this (PangoContext* pangoContext)
140 super(cast(GObject*)pangoContext);
141 this.pangoContext = pangoContext;
155 * Breaks a piece of text into segments with consistent
156 * directional level and shaping engine. Each byte of text will
157 * be contained in exactly one of the items in the returned list;
158 * the generated list of items will be in logical order (the start
159 * offsets of the items are ascending).
160 * cached_iter should be an iterator over attrs currently positioned at a
161 * range before or containing start_index; cached_iter will be advanced to
162 * the range covering the position just after start_index + length.
163 * (i.e. if itemizing in a loop, just keep passing in the same cached_iter).
164 * context:
165 * a structure holding information that affects
166 * the itemization process.
167 * text:
168 * the text to itemize.
169 * start_index:
170 * first byte in text to process
171 * length:
172 * the number of bytes (not characters) to process
173 * after start_index.
174 * This must be >= 0.
175 * attrs:
176 * the set of attributes that apply to text.
177 * cached_iter:
178 * Cached attribute iterator, or NULL
179 * Returns:
180 * a GList of PangoItem structures.
182 public ListG pangoItemize(char[] text, int startIndex, int length, PangoAttrList* attrs, PangoAttrIterator* cachedIter)
184 // GList* pango_itemize (PangoContext *context, const char *text, int start_index, int length, PangoAttrList *attrs, PangoAttrIterator *cached_iter);
185 return new ListG( pango_itemize(pangoContext, Str.toStringz(text), startIndex, length, attrs, cachedIter) );
189 * Like pango_itemize(), but the base direction to use when
190 * computing bidirectional levels (see pango_context_set_base_dir()),
191 * is specified explicitely rather than gotten from the PangoContext.
192 * context:
193 * a structure holding information that affects
194 * the itemization process.
195 * base_dir:
196 * base direction to use for bidirectional processing
197 * text:
198 * the text to itemize.
199 * start_index:
200 * first byte in text to process
201 * length:
202 * the number of bytes (not characters) to process
203 * after start_index.
204 * This must be >= 0.
205 * attrs:
206 * the set of attributes that apply to text.
207 * cached_iter:
208 * Cached attribute iterator, or NULL
209 * Returns:
210 * a GList of PangoItem structures.
211 * Since 1.4
213 public ListG pangoItemizeWithBaseDir(PangoDirection baseDir, char[] text, int startIndex, int length, PangoAttrList* attrs, PangoAttrIterator* cachedIter)
215 // GList* pango_itemize_with_base_dir (PangoContext *context, PangoDirection base_dir, const char *text, int start_index, int length, PangoAttrList *attrs, PangoAttrIterator *cached_iter);
216 return new ListG( pango_itemize_with_base_dir(pangoContext, baseDir, Str.toStringz(text), startIndex, length, attrs, cachedIter) );
224 * From a list of items in logical order and the associated
225 * directional levels, produce a list in visual order.
226 * The original list is unmodified.
227 * logical_items:
228 * a GList of PangoItem in logical order.
229 * Returns:
230 * a GList of PangoItem structures in visual order.
231 * (Please mail otaylorredhat.com if you use this function.
232 * It is not a particularly convenient interface, and the code
233 * is duplicated elsewhere in Pango for that reason.)
235 public static ListG pangoReorderItems(ListG logicalItems)
237 // GList* pango_reorder_items (GList *logical_items);
238 return new ListG( pango_reorder_items((logicalItems is null) ? null : logicalItems.getListGStruct()) );
242 * Creates a new PangoContext initialized to default value.
243 * This function is only useful when implementing a new backend
244 * for Pango, something applications won't do. You should use
245 * the context creation function for the backend you are using,
246 * for example, pango_xft_get_context(), pango_win32_get_context()
247 * or, pango_ft2_font_map_create_context().
248 * If you are using Pango as part of a higher-level system,
249 * that system may have it's own ways of create a PangoContext.
250 * For instance, the GTK+ toolkit has, among others,
251 * gdk_pango_context_get_for_screen(), and
252 * gtk_widget_get_pango_context().
253 * Returns:
254 * the newly allocated PangoContext, which should
255 * be freed with g_object_unref().
257 public this ()
259 // PangoContext* pango_context_new (void);
260 this(cast(PangoContext*)pango_context_new() );
264 * Sets the font map to be searched when fonts are looked-up in this context.
265 * This is only for internal use by Pango backends, a PangoContext obtained
266 * via one of the recommended methods should already have a suitable font map.
267 * context:
268 * a PangoContext
269 * font_map:
270 * the PangoFontMap to set.
272 public void setFontMap(PgFontMap fontMap)
274 // void pango_context_set_font_map (PangoContext *context, PangoFontMap *font_map);
275 pango_context_set_font_map(pangoContext, (fontMap is null) ? null : fontMap.getPgFontMapStruct());
279 * Gets the PangoFontmap used to look up fonts for this context.
280 * context:
281 * a PangoContext
282 * Returns:
283 * the font map for the PangoContext. This value
284 * is owned by Pango and should not be unreferenced.
285 * Since 1.6
287 public PgFontMap getFontMap()
289 // PangoFontMap* pango_context_get_font_map (PangoContext *context);
290 return new PgFontMap( pango_context_get_font_map(pangoContext) );
294 * Retrieve the default font description for the context.
295 * context:
296 * a PangoContext
297 * Returns:
298 * a pointer to the context's default font description.
299 * This value must not be modified or freed.
301 public PgFontDescription getFontDescription()
303 // PangoFontDescription* pango_context_get_font_description (PangoContext *context);
304 return new PgFontDescription( pango_context_get_font_description(pangoContext) );
308 * Set the default font description for the context
309 * context:
310 * a PangoContext
311 * desc:
312 * the new pango font description
314 public void setFontDescription(PgFontDescription desc)
316 // void pango_context_set_font_description (PangoContext *context, const PangoFontDescription *desc);
317 pango_context_set_font_description(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct());
321 * Retrieves the global language tag for the context.
322 * context:
323 * a PangoContext
324 * Returns:
325 * the global language tag.
327 public PgLanguage getLanguage()
329 // PangoLanguage* pango_context_get_language (PangoContext *context);
330 return new PgLanguage( pango_context_get_language(pangoContext) );
334 * Sets the global language tag for the context.
335 * context:
336 * a PangoContext
337 * language:
338 * the new language tag.
340 public void setLanguage(PgLanguage language)
342 // void pango_context_set_language (PangoContext *context, PangoLanguage *language);
343 pango_context_set_language(pangoContext, (language is null) ? null : language.getPgLanguageStruct());
347 * Retrieves the base direction for the context. See
348 * pango_context_set_base_dir().
349 * context:
350 * a PangoContext
351 * Returns:
352 * the base direction for the context.
354 public PangoDirection getBaseDir()
356 // PangoDirection pango_context_get_base_dir (PangoContext *context);
357 return pango_context_get_base_dir(pangoContext);
361 * Sets the base direction for the context.
362 * The base direction is used in applying the Unicode bidirectional
363 * algorithm; if the direction is PANGO_DIRECTION_LTR or
364 * PANGO_DIRECTION_RTL, then the value will be used as the paragraph
365 * direction in the Unicode bidirectional algorithm. A value of
366 * PANGO_DIRECTION_WEAK_LTR or PANGO_DIRECTION_WEAK_RTL is used only
367 * for paragraphs that do not contain any strong characters themselves.
368 * context:
369 * a PangoContext
370 * direction:
371 * the new base direction
373 public void setBaseDir(PangoDirection direction)
375 // void pango_context_set_base_dir (PangoContext *context, PangoDirection direction);
376 pango_context_set_base_dir(pangoContext, direction);
380 * Retrieves the base gravity for the context. See
381 * pango_context_set_base_gravity().
382 * context:
383 * a PangoContext
384 * Returns:
385 * the base gravity for the context.
386 * Since 1.16
388 public PangoGravity getBaseGravity()
390 // PangoGravity pango_context_get_base_gravity (PangoContext *context);
391 return pango_context_get_base_gravity(pangoContext);
395 * Sets the base gravity for the context.
396 * The base gravity is used in laying vertical text out.
397 * context:
398 * a PangoContext
399 * gravity:
400 * the new base gravity
401 * Since 1.16
403 public void setBaseGravity(PangoGravity gravity)
405 // void pango_context_set_base_gravity (PangoContext *context, PangoGravity gravity);
406 pango_context_set_base_gravity(pangoContext, gravity);
410 * Retrieves the gravity for the context. This is similar to
411 * pango_context_get_base_gravity(), except for when the base gravity
412 * is PANGO_GRAVITY_AUTO for which pango_matrix_to_gravity() is used
413 * to return the gravity from the current context matrix.
414 * context:
415 * a PangoContext
416 * Returns:
417 * the resolved gravity for the context.
418 * Since 1.16
420 public PangoGravity getGravity()
422 // PangoGravity pango_context_get_gravity (PangoContext *context);
423 return pango_context_get_gravity(pangoContext);
427 * Gets the transformation matrix that will be applied when
428 * rendering with this context. See pango_context_set_matrix().
429 * context:
430 * a PangoContext
431 * Returns:
432 * the matrix, or NULL if no matrix has been set
433 * (which is the same as the identity matrix). The returned
434 * matrix is owned by Pango and must not be modified or
435 * freed.
436 * Since 1.6
438 public PangoMatrix* getMatrix()
440 // const PangoMatrix* pango_context_get_matrix (PangoContext *context);
441 return pango_context_get_matrix(pangoContext);
445 * Sets the transformation matrix that will be applied when rendering
446 * with this context. Note that reported metrics are in the user space
447 * coordinates before the application of the matrix, not device-space
448 * coordiantes after the application of the matrix. So, they don't scale
449 * with the matrix, though they may change slightly for different
450 * matrices, depending on how the text is fit to the pixel grid.
451 * context:
452 * a PangoContext
453 * matrix:
454 * a PangoMatrix, or NULL to unset any existing matrix.
455 * (No matrix set is the same as setting the identity matrix.)
456 * Since 1.6
458 public void setMatrix(PangoMatrix* matrix)
460 // void pango_context_set_matrix (PangoContext *context, const PangoMatrix *matrix);
461 pango_context_set_matrix(pangoContext, matrix);
465 * Loads the font in one of the fontmaps in the context
466 * that is the closest match for desc.
467 * context:
468 * a PangoContext
469 * desc:
470 * a PangoFontDescription describing the font to load
471 * Returns:
472 * the font loaded, or NULL if no font matched.
474 public PangoFont* loadFont(PgFontDescription desc)
476 // PangoFont* pango_context_load_font (PangoContext *context, const PangoFontDescription *desc);
477 return pango_context_load_font(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct());
481 * Load a set of fonts in the context that can be used to render
482 * a font matching desc.
483 * context:
484 * a PangoContext
485 * desc:
486 * a PangoFontDescription describing the fonts to load
487 * language:
488 * a PangoLanguage the fonts will be used for
489 * Returns:
490 * the fontset, or NULL if no font matched.
492 public PangoFontset* loadFontset(PgFontDescription desc, PgLanguage language)
494 // PangoFontset* pango_context_load_fontset (PangoContext *context, const PangoFontDescription *desc, PangoLanguage *language);
495 return pango_context_load_fontset(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct());
499 * Get overall metric information for a particular font
500 * description. Since the metrics may be substantially different for
501 * different scripts, a language tag can be provided to indicate that
502 * the metrics should be retrieved that correspond to the script(s)
503 * used by that language.
504 * The PangoFontDescription is interpreted in the same way as
505 * by pango_itemize(), and the family name may be a comma separated
506 * list of figures. If characters from multiple of these families
507 * would be used to render the string, then the returned fonts would
508 * be a composite of the metrics for the fonts loaded for the
509 * individual families.
510 * context:
511 * a PangoContext
512 * desc:
513 * a PangoFontDescription structure
514 * language:
515 * language tag used to determine which script to get the metrics
516 * for. NULL means that the language tag from the context will
517 * be used. If no language tag is set on the ccontext, metrics
518 * large enough to cover a range of languages will be returned.
519 * The process of determining such metrics is slow, so it is best
520 * to always make sure some real language tag will be used.
521 * Returns:
522 * a PangoFontMetrics object. The caller must call pango_font_metrics_unref()
523 * when finished using the object.
525 public PgFontMetrics getMetrics(PgFontDescription desc, PgLanguage language)
527 // PangoFontMetrics* pango_context_get_metrics (PangoContext *context, const PangoFontDescription *desc, PangoLanguage *language);
528 return new PgFontMetrics( pango_context_get_metrics(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()) );
532 * List all families for a context.
533 * context:
534 * a PangoContext
535 * families:
536 * location to store a pointer to an array of PangoFontFamily *.
537 * This array should be freed with g_free().
538 * n_families:
539 * location to store the number of elements in descs
541 public void listFamilies(PangoFontFamily*** families, int* nFamilies)
543 // void pango_context_list_families (PangoContext *context, PangoFontFamily ***families, int *n_families);
544 pango_context_list_families(pangoContext, families, nFamilies);
548 * Warning
549 * pango_get_mirror_char is deprecated and should not be used in newly-written code.
550 * If ch has the Unicode mirrored property and there is another Unicode
551 * character that typically has a glyph that is the mirror image of ch's
552 * glyph, puts that character in the address pointed to by mirrored_ch.
553 * Use g_unichar_get_mirror_char() instead; the docs for that function
554 * provide full details.
555 * ch:
556 * a Unicode character
557 * mirrored_ch:
558 * location to store the mirrored character
559 * Returns:
560 * TRUE if ch has a mirrored character and mirrored_ch is
561 * filled in, FALSE otherwise
563 public static int pangoGetMirrorChar(gunichar ch, gunichar* mirroredCh)
565 // gboolean pango_get_mirror_char (gunichar ch, gunichar *mirrored_ch);
566 return pango_get_mirror_char(ch, mirroredCh);
570 * Determines the direction of a character; either
571 * PANGO_DIRECTION_LTR, PANGO_DIRECTION_RTL, or
572 * PANGO_DIRECTION_NEUTRAL.
573 * ch:
574 * a Unicode character
575 * Returns:
576 * the direction of the character, as used in the
577 * Unicode bidirectional algorithm.
579 public static PangoDirection pangoUnicharDirection(gunichar ch)
581 // PangoDirection pango_unichar_direction (gunichar ch);
582 return pango_unichar_direction(ch);
586 * Searches a string the first character that has a strong
587 * direction, according to the Unicode bidirectional algorithm.
588 * text:
589 * the text to process
590 * length:
591 * length of text in bytes (may be -1 if text is nul-terminated)
592 * Returns:
593 * The direction corresponding to the first strong character.
594 * If no such character is found, then PANGO_DIRECTION_NEUTRAL is returned.
595 * Since 1.4
597 public static PangoDirection pangoFindBaseDir(char[] text, int length)
599 // PangoDirection pango_find_base_dir (const gchar *text, gint length);
600 return pango_find_base_dir(Str.toStringz(text), length);
604 * Converts a PangoGravity value to its rotation value.
605 * gravity:
606 * gravity to query
607 * Returns:
608 * the rotation value corresponding to gravity,
609 * or zero if gravity is PANGO_GRAVITY_AUTO
610 * Since 1.16
612 public static double pangoGravityToRotation(PangoGravity gravity)
614 // double pango_gravity_to_rotation (PangoGravity gravity);
615 return pango_gravity_to_rotation(gravity);
619 * Determines possible line, word, and character breaks
620 * for a string of Unicode text with a single analysis. For most
621 * purposes you may want to use pango_get_log_attrs().
622 * text:
623 * the text to process
624 * length:
625 * length of text in bytes (may be -1 if text is nul-terminated)
626 * analysis:
627 * PangoAnalysis structure from pango_itemize()
628 * attrs:
629 * an array to store character information in
630 * attrs_len:
631 * size of the array passed as attrs
633 public static void pangoBreak(char[] text, int length, PangoAnalysis* analysis, PangoLogAttr* attrs, int attrsLen)
635 // void pango_break (const gchar *text, int length, PangoAnalysis *analysis, PangoLogAttr *attrs, int attrs_len);
636 pango_break(Str.toStringz(text), length, analysis, attrs, attrsLen);
640 * Computes a PangoLogAttr for each character in text. The log_attrs
641 * array must have one PangoLogAttr for each position in text; if
642 * text contains N characters, it has N+1 positions, including the
643 * last position at the end of the text. text should be an entire
644 * paragraph; logical attributes can't be computed without context
645 * (for example you need to see spaces on either side of a word to know
646 * the word is a word).
647 * text:
648 * text to process
649 * length:
650 * length in bytes of text
651 * level:
652 * embedding level, or -1 if unknown
653 * language:
654 * language tag
655 * log_attrs:
656 * array with one PangoLogAttr per character in text, plus one extra, to be filled in
657 * attrs_len:
658 * length of log_attrs array
660 public static void pangoGetLogAttrs(char[] text, int length, int level, PgLanguage language, PangoLogAttr* logAttrs, int attrsLen)
662 // void pango_get_log_attrs (const char *text, int length, int level, PangoLanguage *language, PangoLogAttr *log_attrs, int attrs_len);
663 pango_get_log_attrs(Str.toStringz(text), length, level, (language is null) ? null : language.getPgLanguageStruct(), logAttrs, attrsLen);
667 * Locates a paragraph boundary in text. A boundary is caused by
668 * delimiter characters, such as a newline, carriage return, carriage
669 * return-newline pair, or Unicode paragraph separator character. The
670 * index of the run of delimiters is returned in
671 * paragraph_delimiter_index. The index of the start of the paragraph
672 * (index after all delimiters) is stored in next_paragraph_start.
673 * If no delimiters are found, both paragraph_delimiter_index and
674 * next_paragraph_start are filled with the length of text (an index one
675 * off the end).
676 * text:
677 * UTF-8 text
678 * length:
679 * length of text in bytes, or -1 if nul-terminated
680 * paragraph_delimiter_index:
681 * return location for index of delimiter
682 * next_paragraph_start:
683 * return location for start of next paragraph
685 public static void pangoFindParagraphBoundary(char[] text, int length, int* paragraphDelimiterIndex, int* nextParagraphStart)
687 // void pango_find_paragraph_boundary (const gchar *text, gint length, gint *paragraph_delimiter_index, gint *next_paragraph_start);
688 pango_find_paragraph_boundary(Str.toStringz(text), length, paragraphDelimiterIndex, nextParagraphStart);
692 * This is the default break algorithm, used if no language
693 * engine overrides it. Normally you should use pango_break()
694 * instead. Unlike pango_break(),
695 * analysis can be NULL, but only do that if you know what
696 * you're doing. If you need an analysis to pass to pango_break(),
697 * you need to pango_itemize(). In most cases however you should
698 * simply use pango_get_log_attrs().
699 * text:
700 * text to break
701 * length:
702 * length of text in bytes (may be -1 if text is nul-terminated)
703 * analysis:
704 * a PangoAnalysis for the text
705 * attrs:
706 * logical attributes to fill in
707 * attrs_len:
708 * size of the array passed as attrs
710 public static void pangoDefaultBreak(char[] text, int length, PangoAnalysis* analysis, PangoLogAttr* attrs, int attrsLen)
712 // void pango_default_break (const gchar *text, int length, PangoAnalysis *analysis, PangoLogAttr *attrs, int attrs_len);
713 pango_default_break(Str.toStringz(text), length, analysis, attrs, attrsLen);
718 * Given a segment of text and the corresponding
719 * PangoAnalysis structure returned from pango_itemize(),
720 * convert the characters into glyphs. You may also pass
721 * in only a substring of the item from pango_itemize().
722 * text:
723 * the text to process
724 * length:
725 * the length (in bytes) of text
726 * analysis:
727 * PangoAnalysis structure from pango_itemize()
728 * glyphs:
729 * glyph string in which to store results
731 public static void pangoShape(char[] text, int length, PangoAnalysis* analysis, PangoGlyphString* glyphs)
733 // void pango_shape (const gchar *text, gint length, const PangoAnalysis *analysis, PangoGlyphString *glyphs);
734 pango_shape(Str.toStringz(text), length, analysis, glyphs);