1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module pango.c.glyph; 7 8 import pango.c.types; 9 import pango.c.item; 10 import pango.c.font; 11 12 import glib; 13 import gobject; 14 15 import std.bitmanip; 16 17 extern (C): 18 19 /* 1024ths of a device unit */ 20 /** 21 * PangoGlyphUnit: 22 * 23 * The #PangoGlyphUnit type is used to store dimensions within 24 * Pango. Dimensions are stored in 1/%PANGO_SCALE of a device unit. 25 * (A device unit might be a pixel for screen display, or 26 * a point on a printer.) %PANGO_SCALE is currently 1024, and 27 * may change in the future (unlikely though), but you should not 28 * depend on its exact value. The PANGO_PIXELS() macro can be used 29 * to convert from glyph units into device units with correct rounding. 30 */ 31 alias PangoGlyphUnit = gint32; 32 33 /* Positioning information about a glyph 34 */ 35 /** 36 * PangoGlyphGeometry: 37 * @width: the logical width to use for the the character. 38 * @x_offset: horizontal offset from nominal character position. 39 * @y_offset: vertical offset from nominal character position. 40 * 41 * The #PangoGlyphGeometry structure contains width and positioning 42 * information for a single glyph. 43 */ 44 struct PangoGlyphGeometry 45 { 46 PangoGlyphUnit width; 47 PangoGlyphUnit x_offset; 48 PangoGlyphUnit y_offset; 49 } 50 51 /* Visual attributes of a glyph 52 */ 53 /** 54 * PangoGlyphVisAttr: 55 * @is_cluster_start: set for the first logical glyph in each cluster. (Clusters 56 * are stored in visual order, within the cluster, glyphs 57 * are always ordered in logical order, since visual 58 * order is meaningless; that is, in Arabic text, accent glyphs 59 * follow the glyphs for the base character.) 60 * 61 * The PangoGlyphVisAttr is used to communicate information between 62 * the shaping phase and the rendering phase. More attributes may be 63 * added in the future. 64 */ 65 struct PangoGlyphVisAttr 66 { 67 mixin(bitfields!( 68 guint, "is_cluster_start", 1, 69 guint, "", 7)); 70 } 71 72 /* A single glyph 73 */ 74 /** 75 * PangoGlyphInfo: 76 * @glyph: the glyph itself. 77 * @geometry: the positional information about the glyph. 78 * @attr: the visual attributes of the glyph. 79 * 80 * The #PangoGlyphInfo structure represents a single glyph together with 81 * positioning information and visual attributes. 82 * It contains the following fields. 83 */ 84 struct PangoGlyphInfo 85 { 86 PangoGlyph glyph; 87 PangoGlyphGeometry geometry; 88 PangoGlyphVisAttr attr; 89 } 90 91 /* A string of glyphs with positional information and visual attributes - 92 * ready for drawing 93 */ 94 /** 95 * PangoGlyphString: 96 * 97 * The #PangoGlyphString structure is used to store strings 98 * of glyphs with geometry and visual attribute information. 99 * The storage for the glyph information is owned 100 * by the structure which simplifies memory management. 101 */ 102 struct PangoGlyphString { 103 gint num_glyphs; 104 105 PangoGlyphInfo *glyphs; 106 107 /* This is a memory inefficient way of representing the information 108 * here - each value gives the byte index within the text 109 * corresponding to the glyph string of the start of the cluster to 110 * which the glyph belongs. 111 */ 112 gint *log_clusters; 113 114 /*< private >*/ 115 gint space; 116 } 117 118 119 PangoGlyphString *pango_glyph_string_new (); 120 void pango_glyph_string_set_size (PangoGlyphString *str, 121 gint new_len); 122 pure GType pango_glyph_string_get_type (); 123 PangoGlyphString *pango_glyph_string_copy (PangoGlyphString *str); 124 void pango_glyph_string_free (PangoGlyphString *str); 125 void pango_glyph_string_extents (PangoGlyphString *glyphs, 126 PangoFont *font, 127 PangoRectangle *ink_rect, 128 PangoRectangle *logical_rect); 129 int pango_glyph_string_get_width(PangoGlyphString *glyphs); 130 131 void pango_glyph_string_extents_range (PangoGlyphString *glyphs, 132 int start, 133 int end, 134 PangoFont *font, 135 PangoRectangle *ink_rect, 136 PangoRectangle *logical_rect); 137 138 void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs, 139 const(char) *text, 140 int length, 141 int embedding_level, 142 int *logical_widths); 143 144 void pango_glyph_string_index_to_x (PangoGlyphString *glyphs, 145 char *text, 146 int length, 147 PangoAnalysis *analysis, 148 int index_, 149 gboolean trailing, 150 int *x_pos); 151 void pango_glyph_string_x_to_index (PangoGlyphString *glyphs, 152 char *text, 153 int length, 154 PangoAnalysis *analysis, 155 int x_pos, 156 int *index_, 157 int *trailing); 158 159 /* Turn a string of characters into a string of glyphs 160 */ 161 void pango_shape (const(gchar) *text, 162 gint length, 163 const(PangoAnalysis) *analysis, 164 PangoGlyphString *glyphs); 165 166 void pango_shape_full (const(gchar) *item_text, 167 gint item_length, 168 const(gchar) *paragraph_text, 169 gint paragraph_length, 170 const(PangoAnalysis) *analysis, 171 PangoGlyphString *glyphs); 172 173 GList *pango_reorder_items (GList *logical_items); 174