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.PgFontMap; 26 27 private import glib.Str; 28 private import gobject.ObjectG; 29 private import gtkc.pango; 30 public import gtkc.pangotypes; 31 private import pango.PgContext; 32 private import pango.PgFont; 33 private import pango.PgFontDescription; 34 private import pango.PgFontFamily; 35 private import pango.PgFontset; 36 private import pango.PgLanguage; 37 38 39 /** 40 * The #PangoFontMap represents the set of fonts available for a 41 * particular rendering system. This is a virtual object with 42 * implementations being specific to particular rendering systems. To 43 * create an implementation of a #PangoFontMap, the rendering-system 44 * specific code should allocate a larger structure that contains a nested 45 * #PangoFontMap, fill in the <structfield>klass</structfield> member of the nested #PangoFontMap with a 46 * pointer to a appropriate #PangoFontMapClass, then call 47 * pango_font_map_init() on the structure. 48 * 49 * The #PangoFontMap structure contains one member which the implementation 50 * fills in. 51 */ 52 public class PgFontMap : ObjectG 53 { 54 /** the main Gtk struct */ 55 protected PangoFontMap* pangoFontMap; 56 57 /** Get the main Gtk struct */ 58 public PangoFontMap* getPgFontMapStruct(bool transferOwnership = false) 59 { 60 if (transferOwnership) 61 ownedRef = false; 62 return pangoFontMap; 63 } 64 65 /** the main Gtk struct as a void* */ 66 protected override void* getStruct() 67 { 68 return cast(void*)pangoFontMap; 69 } 70 71 protected override void setStruct(GObject* obj) 72 { 73 pangoFontMap = cast(PangoFontMap*)obj; 74 super.setStruct(obj); 75 } 76 77 /** 78 * Sets our main struct and passes it to the parent class. 79 */ 80 public this (PangoFontMap* pangoFontMap, bool ownedRef = false) 81 { 82 this.pangoFontMap = pangoFontMap; 83 super(cast(GObject*)pangoFontMap, ownedRef); 84 } 85 86 87 /** */ 88 public static GType getType() 89 { 90 return pango_font_map_get_type(); 91 } 92 93 /** 94 * Forces a change in the context, which will cause any #PangoContext 95 * using this fontmap to change. 96 * 97 * This function is only useful when implementing a new backend 98 * for Pango, something applications won't do. Backends should 99 * call this function if they have attached extra data to the context 100 * and such data is changed. 101 * 102 * Since: 1.34 103 */ 104 public void changed() 105 { 106 pango_font_map_changed(pangoFontMap); 107 } 108 109 /** 110 * Creates a #PangoContext connected to @fontmap. This is equivalent 111 * to pango_context_new() followed by pango_context_set_font_map(). 112 * 113 * If you are using Pango as part of a higher-level system, 114 * that system may have it's own way of create a #PangoContext. 115 * For instance, the GTK+ toolkit has, among others, 116 * gdk_pango_context_get_for_screen(), and 117 * gtk_widget_get_pango_context(). Use those instead. 118 * 119 * Returns: the newly allocated #PangoContext, 120 * which should be freed with g_object_unref(). 121 * 122 * Since: 1.22 123 */ 124 public PgContext createContext() 125 { 126 auto p = pango_font_map_create_context(pangoFontMap); 127 128 if(p is null) 129 { 130 return null; 131 } 132 133 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true); 134 } 135 136 /** 137 * Returns the current serial number of @fontmap. The serial number is 138 * initialized to an small number larger than zero when a new fontmap 139 * is created and is increased whenever the fontmap is changed. It may 140 * wrap, but will never have the value 0. Since it can wrap, never compare 141 * it with "less than", always use "not equals". 142 * 143 * The fontmap can only be changed using backend-specific API, like changing 144 * fontmap resolution. 145 * 146 * This can be used to automatically detect changes to a #PangoFontMap, like 147 * in #PangoContext. 148 * 149 * Returns: The current serial number of @fontmap. 150 * 151 * Since: 1.32.4 152 */ 153 public uint getSerial() 154 { 155 return pango_font_map_get_serial(pangoFontMap); 156 } 157 158 /** 159 * Returns the render ID for shape engines for this fontmap. 160 * See the <structfield>render_type</structfield> field of 161 * #PangoEngineInfo. 162 * 163 * Returns: the ID string for shape engines for 164 * this fontmap. Owned by Pango, should not be modified 165 * or freed. 166 * 167 * Since: 1.4 168 */ 169 public string getShapeEngineType() 170 { 171 return Str.toString(pango_font_map_get_shape_engine_type(pangoFontMap)); 172 } 173 174 /** 175 * List all families for a fontmap. 176 * 177 * Params: 178 * families = location to store a pointer to an array of #PangoFontFamily *. 179 * This array should be freed with g_free(). 180 * nFamilies = location to store the number of elements in @families 181 */ 182 public void listFamilies(out PgFontFamily[] families) 183 { 184 PangoFontFamily** outfamilies = null; 185 int nFamilies; 186 187 pango_font_map_list_families(pangoFontMap, &outfamilies, &nFamilies); 188 189 families = new PgFontFamily[nFamilies]; 190 for(size_t i = 0; i < nFamilies; i++) 191 { 192 families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]); 193 } 194 } 195 196 /** 197 * Load the font in the fontmap that is the closest match for @desc. 198 * 199 * Params: 200 * context = the #PangoContext the font will be used with 201 * desc = a #PangoFontDescription describing the font to load 202 * 203 * Returns: the newly allocated #PangoFont 204 * loaded, or %NULL if no font matched. 205 */ 206 public PgFont loadFont(PgContext context, PgFontDescription desc) 207 { 208 auto p = pango_font_map_load_font(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct()); 209 210 if(p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p, true); 216 } 217 218 /** 219 * Load a set of fonts in the fontmap that can be used to render 220 * a font matching @desc. 221 * 222 * Params: 223 * context = the #PangoContext the font will be used with 224 * desc = a #PangoFontDescription describing the font to load 225 * language = a #PangoLanguage the fonts will be used for 226 * 227 * Returns: the newly allocated 228 * #PangoFontset loaded, or %NULL if no font matched. 229 */ 230 public PgFontset loadFontset(PgContext context, PgFontDescription desc, PgLanguage language) 231 { 232 auto p = pango_font_map_load_fontset(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()); 233 234 if(p is null) 235 { 236 return null; 237 } 238 239 return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) p, true); 240 } 241 }