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