2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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-Glyph-Storage.html
27 * outFile = PgGlyphString
28 * strct = PangoGlyphString
31 * clss = PgGlyphString
39 * - pango_glyph_string_
48 * - pango.PgFontDescription
49 * - pango.PgFontMetrics
50 * - pango.PgFontFamily
53 * - pango.PgFontsetSimple
55 * - pango.PgAttributeList
59 * - pango.PgLayoutIter
60 * - pango.PgScriptIter
64 * - PangoAttribute* -> PgAttribute
65 * - PangoAttributeList* -> PgAttributeList
66 * - PangoContext* -> PgContext
67 * - PangoFontDescription* -> PgFontDescription
68 * - PangoFontFace* -> PgFontFace
69 * - PangoFontFamily* -> PgFontFamily
70 * - PangoFontMap* -> PgFontMap
71 * - PangoFontMetrics* -> PgFontMetrics
72 * - PangoFontsetSimple* -> PgFontsetSimple
73 * - PangoItem* -> PgItem
74 * - PangoLanguage* -> PgLanguage
75 * - PangoLayout* -> PgLayout
76 * - PangoLayoutIter* -> PgLayoutIter
77 * - PangoScriptIter* -> PgScriptIter
78 * - PangoTabArray* -> PgTabArray
83 module pango
.PgGlyphString
;
89 import tango
.io
.Stdout
; // use the tango loging?
93 private import gtkc
.pangotypes
;
95 private import gtkc
.pango
;
98 private import glib
.ListSG
;
99 private import pango
.PgContext
;
100 private import pango
.PgItem
;
101 private import pango
.PgLayout
;
102 private import pango
.PgFontDescription
;
103 private import pango
.PgFontMetrics
;
104 private import pango
.PgFontFamily
;
105 private import pango
.PgFontFace
;
106 private import pango
.PgFontMap
;
107 private import pango
.PgFontsetSimple
;
108 private import pango
.PgAttribute
;
109 private import pango
.PgAttributeList
;
110 private import pango
.PgLanguage
;
111 private import pango
.PgTabArray
;
112 private import pango
.PgLayout
;
113 private import pango
.PgLayoutIter
;
114 private import pango
.PgScriptIter
;
115 private import glib
.Str
;
122 * pango_shape() produces a string of glyphs which
123 * can be measured or drawn to the screen. The following
124 * structures are used to store information about
127 public class PgGlyphString
130 /** the main Gtk struct */
131 protected PangoGlyphString
* pangoGlyphString
;
134 public PangoGlyphString
* getPgGlyphStringStruct()
136 return pangoGlyphString
;
140 /** the main Gtk struct as a void* */
141 protected void* getStruct()
143 return cast(void*)pangoGlyphString
;
147 * Sets our main struct and passes it to the parent class
149 public this (PangoGlyphString
* pangoGlyphString
)
153 if ( pangoGlyphString
is null )
158 Stdout("struct pangoGlyphString is null on constructor").newline
;
162 printf("struct pangoGlyphString is null on constructor");
169 assert(pangoGlyphString
!is null, "struct pangoGlyphString is null on constructor");
171 this.pangoGlyphString
= pangoGlyphString
;
182 * Converts a number in Pango units to floating-point: divides
185 * value in Pango units
190 public static double pangoUnitsToDouble(int i
)
192 // double pango_units_to_double (int i);
193 return pango_units_to_double(i
);
197 * Converts a floating-point number to Pango units: multiplies
198 * it by PANGO_SCALE and rounds to nearest integer.
200 * double floating-point value
202 * the value in Pango units.
205 public static int pangoUnitsFromDouble(double d
)
207 // int pango_units_from_double (double d);
208 return pango_units_from_double(d
);
217 * Converts extents from Pango units to device units, dividing by the
218 * PANGO_SCALE factor and performing rounding.
219 * The ink rectangle is converted by flooring the x/y coordinates and extending
220 * width/height, such that the final rectangle completely includes the original
222 * The logical rectangle is converted by rounding the coordinates
223 * of the rectangle to the nearest device unit.
224 * Note that in certain situations you may want pass a logical extents
225 * rectangle to this function as ink_rect. The rule is: if you want the
226 * resulting device-space rectangle to completely contain the original
227 * rectangle, pass it in as ink_rect.
229 * ink rectangle to convert, or NULL.
231 * logical rectangle to convert, or NULL.
234 public static void pangoExtentsToPixels(PangoRectangle
* inkRect
, PangoRectangle
* logicalRect
)
236 // void pango_extents_to_pixels (PangoRectangle *ink_rect, PangoRectangle *logical_rect);
237 pango_extents_to_pixels(inkRect
, logicalRect
);
244 * Copies a PangoMatrix.
246 * a PangoMatrix, can be NULL
248 * the newly allocated PangoMatrix, which should
249 * be freed with pango_matrix_free(), or NULL if
253 public static PangoMatrix
* pangoMatrixCopy(PangoMatrix
* matrix
)
255 // PangoMatrix* pango_matrix_copy (const PangoMatrix *matrix);
256 return pango_matrix_copy(matrix
);
260 * Free a PangoMatrix created with pango_matrix_copy().
261 * Does nothing if matrix is NULL.
263 * a PangoMatrix, or NULL
266 public static void pangoMatrixFree(PangoMatrix
* matrix
)
268 // void pango_matrix_free (PangoMatrix *matrix);
269 pango_matrix_free(matrix
);
273 * Changes the transformation represented by matrix to be the
274 * transformation given by first translating by (tx, ty)
275 * then applying the original transformation.
279 * amount to translate in the X direction
281 * amount to translate in the Y direction
284 public static void pangoMatrixTranslate(PangoMatrix
* matrix
, double tx
, double ty
)
286 // void pango_matrix_translate (PangoMatrix *matrix, double tx, double ty);
287 pango_matrix_translate(matrix
, tx
, ty
);
291 * Changes the transformation represented by matrix to be the
292 * transformation given by first scaling by sx in the X direction
293 * and sy in the Y direction then applying the original
298 * amount to scale by in X direction
300 * amount to scale by in Y direction
303 public static void pangoMatrixScale(PangoMatrix
* matrix
, double scaleX
, double scaleY
)
305 // void pango_matrix_scale (PangoMatrix *matrix, double scale_x, double scale_y);
306 pango_matrix_scale(matrix
, scaleX
, scaleY
);
310 * Changes the transformation represented by matrix to be the
311 * transformation given by first rotating by degrees degrees
312 * counter-clockwise then applying the original transformation.
316 * degrees to rotate counter-clockwise
319 public static void pangoMatrixRotate(PangoMatrix
* matrix
, double degrees
)
321 // void pango_matrix_rotate (PangoMatrix *matrix, double degrees);
322 pango_matrix_rotate(matrix
, degrees
);
326 * Changes the transformation represented by matrix to be the
327 * transformation given by first applying transformation
328 * given by new_matrix then applying the original transformation.
335 public static void pangoMatrixConcat(PangoMatrix
* matrix
, PangoMatrix
* newMatrix
)
337 // void pango_matrix_concat (PangoMatrix *matrix, const PangoMatrix *new_matrix);
338 pango_matrix_concat(matrix
, newMatrix
);
342 * Transforms the point (x, y) by matrix.
344 * a PangoMatrix, or NULL
351 public static void pangoMatrixTransformPoint(PangoMatrix
* matrix
, double* x
, double* y
)
353 // void pango_matrix_transform_point (const PangoMatrix *matrix, double *x, double *y);
354 pango_matrix_transform_point(matrix
, x
, y
);
358 * Transforms the distance vector (dx,dy) by matrix. This is
359 * similar to pango_matrix_transform_point() except that the translation
360 * components of the transformation are ignored. The calculation of
361 * the returned vector is as follows:
362 * dx2 = dx1 * xx + dy1 * xy;
363 * dy2 = dx1 * yx + dy1 * yy;
364 * Affine transformations are position invariant, so the same vector
365 * always transforms to the same vector. If (x1,y1) transforms
366 * to (x2,y2) then (x1+dx1,y1+dy1) will transform to
367 * (x1+dx2,y1+dy2) for all values of x1 and x2.
369 * a PangoMatrix, or NULL
371 * in/out X component of a distance vector
373 * yn/out Y component of a distance vector
376 public static void pangoMatrixTransformDistance(PangoMatrix
* matrix
, double* dx
, double* dy
)
378 // void pango_matrix_transform_distance (const PangoMatrix *matrix, double *dx, double *dy);
379 pango_matrix_transform_distance(matrix
, dx
, dy
);
383 * First transforms rect using matrix, then calculates the bounding box
384 * of the transformed rectangle. The rectangle should be in Pango units.
385 * This function is useful for example when you want to draw a rotated
386 * PangoLayout to an image buffer, and want to know how large the image
387 * should be and how much you should shift the layout when rendering.
388 * If you have a rectangle in device units (pixels), use
389 * pango_matrix_transform_pixel_rectangle().
390 * If you have the rectangle in Pango units and want to convert to
391 * transformed pixel bounding box, it is more accurate to transform it first
392 * (using this function) and pass the result to pango_extents_to_pixels(),
393 * as ink_rect. However, there is a reason that you may want to convert
394 * to pixels first and then transform, and that is when the transformed
395 * coordinates may overflow in Pango units (large matrix translation for
398 * a PangoMatrix, or NULL
400 * in/out bounding box in Pango units, or NULL
403 public static void pangoMatrixTransformRectangle(PangoMatrix
* matrix
, PangoRectangle
* rect
)
405 // void pango_matrix_transform_rectangle (const PangoMatrix *matrix, PangoRectangle *rect);
406 pango_matrix_transform_rectangle(matrix
, rect
);
410 * First transforms the rect using matrix, then calculates the bounding box
411 * of the transformed rectangle. The rectangle should be in device units
413 * This function is useful for example when you want to draw a rotated
414 * PangoLayout to an image buffer, and want to know how large the image
415 * should be and how much you should shift the layout when rendering.
416 * For better accuracy, you should use pango_matrix_transform_rectangle() on
417 * original rectangle in Pango units and convert to pixels afterward
418 * using pango_extents_to_pixels() as ink_rect.
420 * a PangoMatrix, or NULL
422 * in/out bounding box in device units, or NULL
425 public static void pangoMatrixTransformPixelRectangle(PangoMatrix
* matrix
, PangoRectangle
* rect
)
427 // void pango_matrix_transform_pixel_rectangle (const PangoMatrix *matrix, PangoRectangle *rect);
428 pango_matrix_transform_pixel_rectangle(matrix
, rect
);
432 * Returns the scale factor of a matrix on the height of the font.
433 * That is, the scale factor in the direction perpendicular to the
434 * vector that the X coordinate is mapped to.
436 * a PangoMatrix, may be NULL
438 * the scale factor of matrix on the height of the font,
439 * or 1.0 if matrix is NULL.
442 public static double pangoMatrixGetFontScaleFactor(PangoMatrix
* matrix
)
444 // double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix);
445 return pango_matrix_get_font_scale_factor(matrix
);
460 * Create a new PangoGlyphString.
462 * the newly allocated PangoGlyphString, which
463 * should be freed with pango_glyph_string_free().
467 // PangoGlyphString* pango_glyph_string_new (void);
468 this(cast(PangoGlyphString
*)pango_glyph_string_new() );
472 * Copy a glyph string and associated storage.
474 * a PangoGlyphString.
476 * the newly allocated PangoGlyphString, which
477 * should be freed with pango_glyph_string_free().
479 public PangoGlyphString
* copy()
481 // PangoGlyphString* pango_glyph_string_copy (PangoGlyphString *string);
482 return pango_glyph_string_copy(pangoGlyphString
);
486 * Resize a glyph string to the given length.
488 * a PangoGlyphString.
490 * the new length of the string.
492 public void setSize(int newLen
)
494 // void pango_glyph_string_set_size (PangoGlyphString *string, gint new_len);
495 pango_glyph_string_set_size(pangoGlyphString
, newLen
);
499 * Free a glyph string and associated storage.
501 * a PangoGlyphString.
505 // void pango_glyph_string_free (PangoGlyphString *string);
506 pango_glyph_string_free(pangoGlyphString
);
510 * Compute the logical and ink extents of a glyph string. See the documentation
511 * for pango_font_get_glyph_extents() for details about the interpretation
518 * rectangle used to store the extents of the glyph string as drawn
519 * or NULL to indicate that the result is not needed.
521 * rectangle used to store the logical extents of the glyph string
522 * or NULL to indicate that the result is not needed.
524 public void extents(PangoFont
* font
, PangoRectangle
* inkRect
, PangoRectangle
* logicalRect
)
526 // void pango_glyph_string_extents (PangoGlyphString *glyphs, PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
527 pango_glyph_string_extents(pangoGlyphString
, font
, inkRect
, logicalRect
);
531 * Computes the extents of a sub-portion of a glyph string. The extents are
532 * relative to the start of the glyph string range (the origin of their
533 * coordinate system is at the start of the range, not at the start of the entire
540 * end index (the range is the set of bytes with
541 * indices such that start <= index < end)
545 * rectangle used to store the extents of the glyph string range as drawn
546 * or NULL to indicate that the result is not needed.
548 * rectangle used to store the logical extents of the glyph string range
549 * or NULL to indicate that the result is not needed.
551 public void extentsRange(int start
, int end
, PangoFont
* font
, PangoRectangle
* inkRect
, PangoRectangle
* logicalRect
)
553 // void pango_glyph_string_extents_range (PangoGlyphString *glyphs, int start, int end, PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
554 pango_glyph_string_extents_range(pangoGlyphString
, start
, end
, font
, inkRect
, logicalRect
);
558 * Computes the logical width of the glyph string as can also be computed
559 * using pango_glyph_string_extents(). However, since this only computes the
560 * width, it's much faster. This is in fact only a convenience function that
561 * computes the sum of geometry.width for each glyph in the glyphs.
565 * the logical width of the glyph string.
568 public int getWidth()
570 // int pango_glyph_string_get_width (PangoGlyphString *glyphs);
571 return pango_glyph_string_get_width(pangoGlyphString
);
575 * Converts from character position to x position. (X position
576 * is measured from the left edge of the run). Character positions
577 * are computed by dividing up each cluster into equal portions.
579 * the glyphs return from pango_shape()
581 * the text for the run
583 * the number of bytes (not characters) in text.
585 * the analysis information return from pango_itemize()
587 * the byte index within text
589 * whether we should compute the result for the beginning
590 * or end of the character.
592 * location to store result
594 public void indexToX(char[] text
, int length
, PangoAnalysis
* analysis
, int index
, int trailing
, int* xPos
)
596 // void pango_glyph_string_index_to_x (PangoGlyphString *glyphs, char *text, int length, PangoAnalysis *analysis, int index_, gboolean trailing, int *x_pos);
597 pango_glyph_string_index_to_x(pangoGlyphString
, Str
.toStringz(text
), length
, analysis
, index
, trailing
, xPos
);
601 * Convert from x offset to character position. Character positions
602 * are computed by dividing up each cluster into equal portions.
603 * In scripts where positioning within a cluster is not allowed
604 * (such as Thai), the returned value may not be a valid cursor
605 * position; the caller must combine the result with the logical
606 * attributes for the text to compute the valid cursor position.
608 * the glyphs return from pango_shape()
610 * the text for the run
612 * the number of bytes (not characters) in text.
614 * the analysis information return from pango_itemize()
616 * the x offset (in PangoGlyphUnit)
618 * location to store calculated byte index within text
620 * location to store a integer indicating where
621 * whether the user clicked on the leading or trailing
622 * edge of the character.
624 public void xToIndex(char[] text
, int length
, PangoAnalysis
* analysis
, int xPos
, int* index
, int* trailing
)
626 // void pango_glyph_string_x_to_index (PangoGlyphString *glyphs, char *text, int length, PangoAnalysis *analysis, int x_pos, int *index_, int *trailing);
627 pango_glyph_string_x_to_index(pangoGlyphString
, Str
.toStringz(text
), length
, analysis
, xPos
, index
, trailing
);
631 * Given a PangoGlyphString resulting from pango_shape() and the corresponding
632 * text, determine the screen width corresponding to each character. When
633 * multiple characters compose a single cluster, the width of the entire
634 * cluster is divided equally among the characters.
638 * the text corresponding to the glyphs
640 * the length of text, in bytes
642 * the embedding level of the string
644 * an array whose length is g_utf8_strlen (text, length)
645 * to be filled in with the resulting character widths.
647 public void getLogicalWidths(char[] text
, int length
, int embeddingLevel
, int* logicalWidths
)
649 // void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs, const char *text, int length, int embedding_level, int *logical_widths);
650 pango_glyph_string_get_logical_widths(pangoGlyphString
, Str
.toStringz(text
), length
, embeddingLevel
, logicalWidths
);
654 * Modifies orig to cover only the text after split_index, and
655 * returns a new item that covers the text before split_index that
656 * used to be in orig. You can think of split_index as the length of
657 * the returned item. split_index may not be 0, and it may not be
658 * greater than or equal to the length of orig (that is, there must
659 * be at least one byte assigned to each item, you can't create a
661 * This function is similar in function to pango_item_split() (and uses
666 * text to which positions in orig apply
668 * byte index of position to split item, relative to the start of the item
670 * the newly allocated item representing text before
671 * split_index, which should be freed
672 * with pango_glyph_item_free().
675 public static PangoGlyphItem
* pangoGlyphItemSplit(PangoGlyphItem
* orig
, char[] text
, int splitIndex
)
677 // PangoGlyphItem* pango_glyph_item_split (PangoGlyphItem *orig, const char *text, int split_index);
678 return pango_glyph_item_split(orig
, Str
.toStringz(text
), splitIndex
);
682 * Splits a shaped item (PangoGlyphItem) into multiple items based
683 * on an attribute list. The idea is that if you have attributes
684 * that don't affect shaping, such as color or underline, to avoid
685 * affecting shaping, you filter them out (pango_attr_list_filter()),
686 * apply the shaping process and then reapply them to the result using
688 * All attributes that start or end inside a cluster are applied
689 * to that cluster; for instance, if half of a cluster is underlined
690 * and the other-half strikethrough, then the cluster will end
691 * up with both underline and strikethrough attributes. In these
692 * cases, it may happen that item->extra_attrs for some of the
693 * result items can have multiple attributes of the same type.
694 * This function takes ownership of glyph_item; it will be reused
695 * as one of the elements in the list.
699 * text that list applies to
703 * a list of glyph items resulting from splitting
704 * glyph_item. Free the elements using pango_glyph_item_free(),
705 * the list using g_slist_free().
708 public static ListSG
pangoGlyphItemApplyAttrs(PangoGlyphItem
* glyphItem
, char[] text
, PangoAttrList
* list
)
710 // GSList* pango_glyph_item_apply_attrs (PangoGlyphItem *glyph_item, const char *text, PangoAttrList *list);
711 return new ListSG( pango_glyph_item_apply_attrs(glyphItem
, Str
.toStringz(text
), list
) );
715 * Adds spacing between the graphemes of glyph_item to
716 * give the effect of typographic letter spacing.
720 * text that glyph_item corresponds to
721 * (glyph_item->item->offset is an offset from the
724 * logical attributes for the item (the
725 * first logical attribute refers to the position
726 * before the first character in the item)
728 * amount of letter spacing to add
729 * in Pango units. May be negative, though too large
730 * negative values will give ugly results.
733 public static void pangoGlyphItemLetterSpace(PangoGlyphItem
* glyphItem
, char[] text
, PangoLogAttr
* logAttrs
, int letterSpacing
)
735 // void pango_glyph_item_letter_space (PangoGlyphItem *glyph_item, const char *text, PangoLogAttr *log_attrs, int letter_spacing);
736 pango_glyph_item_letter_space(glyphItem
, Str
.toStringz(text
), logAttrs
, letterSpacing
);
740 * Frees a PangoGlyphItem and memory to which it points.
745 public static void pangoGlyphItemFree(PangoGlyphItem
* glyphItem
)
747 // void pango_glyph_item_free (PangoGlyphItem *glyph_item);
748 pango_glyph_item_free(glyphItem
);