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.PgGlyphItem; 26 27 private import glib.ListSG; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtkc.pango; 31 public import gtkc.pangotypes; 32 private import pango.PgAttributeList; 33 34 35 /** 36 * A #PangoGlyphItem is a pair of a #PangoItem and the glyphs 37 * resulting from shaping the text corresponding to an item. 38 * As an example of the usage of #PangoGlyphItem, the results 39 * of shaping text with #PangoLayout is a list of #PangoLayoutLine, 40 * each of which contains a list of #PangoGlyphItem. 41 */ 42 public class PgGlyphItem 43 { 44 /** the main Gtk struct */ 45 protected PangoGlyphItem* pangoGlyphItem; 46 47 /** Get the main Gtk struct */ 48 public PangoGlyphItem* getPgGlyphItemStruct() 49 { 50 return pangoGlyphItem; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected void* getStruct() 55 { 56 return cast(void*)pangoGlyphItem; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (PangoGlyphItem* pangoGlyphItem) 63 { 64 this.pangoGlyphItem = pangoGlyphItem; 65 } 66 67 68 /** */ 69 public static GType getType() 70 { 71 return pango_glyph_item_get_type(); 72 } 73 74 /** 75 * Splits a shaped item (PangoGlyphItem) into multiple items based 76 * on an attribute list. The idea is that if you have attributes 77 * that don't affect shaping, such as color or underline, to avoid 78 * affecting shaping, you filter them out (pango_attr_list_filter()), 79 * apply the shaping process and then reapply them to the result using 80 * this function. 81 * 82 * All attributes that start or end inside a cluster are applied 83 * to that cluster; for instance, if half of a cluster is underlined 84 * and the other-half strikethrough, then the cluster will end 85 * up with both underline and strikethrough attributes. In these 86 * cases, it may happen that item->extra_attrs for some of the 87 * result items can have multiple attributes of the same type. 88 * 89 * This function takes ownership of @glyph_item; it will be reused 90 * as one of the elements in the list. 91 * 92 * Params: 93 * text = text that @list applies to 94 * list = a #PangoAttrList 95 * 96 * Return: a 97 * list of glyph items resulting from splitting @glyph_item. Free 98 * the elements using pango_glyph_item_free(), the list using 99 * g_slist_free(). 100 * 101 * Since: 1.2 102 */ 103 public ListSG applyAttrs(string text, PgAttributeList list) 104 { 105 auto p = pango_glyph_item_apply_attrs(pangoGlyphItem, Str.toStringz(text), (list is null) ? null : list.getPgAttributeListStruct()); 106 107 if(p is null) 108 { 109 return null; 110 } 111 112 return new ListSG(cast(GSList*) p); 113 } 114 115 /** 116 * Make a deep copy of an existing #PangoGlyphItem structure. 117 * 118 * Return: the newly allocated #PangoGlyphItem, which should 119 * be freed with pango_glyph_item_free(), or %NULL 120 * if @orig was %NULL. 121 * 122 * Since: 1.20 123 */ 124 public PgGlyphItem copy() 125 { 126 auto p = pango_glyph_item_copy(pangoGlyphItem); 127 128 if(p is null) 129 { 130 return null; 131 } 132 133 return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) p); 134 } 135 136 /** 137 * Frees a #PangoGlyphItem and resources to which it points. 138 * 139 * Since: 1.6 140 */ 141 public void free() 142 { 143 pango_glyph_item_free(pangoGlyphItem); 144 } 145 146 /** 147 * Given a #PangoGlyphItem and the corresponding 148 * text, determine the screen width corresponding to each character. When 149 * multiple characters compose a single cluster, the width of the entire 150 * cluster is divided equally among the characters. 151 * 152 * See also pango_glyph_string_get_logical_widths(). 153 * 154 * Params: 155 * text = text that @glyph_item corresponds to 156 * (glyph_item->item->offset is an offset from the 157 * start of @text) 158 * logicalWidths = an array whose length is the number of 159 * characters in glyph_item (equal to 160 * glyph_item->item->num_chars) to be filled in with 161 * the resulting character widths. 162 * 163 * Since: 1.26 164 */ 165 public void getLogicalWidths(string text, int[] logicalWidths) 166 { 167 pango_glyph_item_get_logical_widths(pangoGlyphItem, Str.toStringz(text), logicalWidths.ptr); 168 } 169 170 /** 171 * Adds spacing between the graphemes of @glyph_item to 172 * give the effect of typographic letter spacing. 173 * 174 * Params: 175 * text = text that @glyph_item corresponds to 176 * (glyph_item->item->offset is an offset from the 177 * start of @text) 178 * logAttrs = logical attributes for the item 179 * (the first logical attribute refers to the position 180 * before the first character in the item) 181 * letterSpacing = amount of letter spacing to add 182 * in Pango units. May be negative, though too large 183 * negative values will give ugly results. 184 * 185 * Since: 1.6 186 */ 187 public void letterSpace(string text, PangoLogAttr[] logAttrs, int letterSpacing) 188 { 189 pango_glyph_item_letter_space(pangoGlyphItem, Str.toStringz(text), logAttrs.ptr, letterSpacing); 190 } 191 192 /** 193 * Modifies @orig to cover only the text after @split_index, and 194 * returns a new item that covers the text before @split_index that 195 * used to be in @orig. You can think of @split_index as the length of 196 * the returned item. @split_index may not be 0, and it may not be 197 * greater than or equal to the length of @orig (that is, there must 198 * be at least one byte assigned to each item, you can't create a 199 * zero-length item). 200 * 201 * This function is similar in function to pango_item_split() (and uses 202 * it internally.) 203 * 204 * Params: 205 * text = text to which positions in @orig apply 206 * splitIndex = byte index of position to split item, relative to the start of the item 207 * 208 * Return: the newly allocated item representing text before 209 * @split_index, which should be freed 210 * with pango_glyph_item_free(). 211 * 212 * Since: 1.2 213 */ 214 public PgGlyphItem split(string text, int splitIndex) 215 { 216 auto p = pango_glyph_item_split(pangoGlyphItem, Str.toStringz(text), splitIndex); 217 218 if(p is null) 219 { 220 return null; 221 } 222 223 return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) p); 224 } 225 }