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 public import gtkc.pangotypes; 30 private import pango.PgContext; 31 private import pango.PgFont; 32 private import pango.PgFontDescription; 33 private import pango.PgFontFamily; 34 private import pango.PgFontset; 35 private import pango.PgLanguage; 36 private import pango.c.functions; 37 public import pango.c.types; 38 39 40 /** 41 * The #PangoFontMap represents the set of fonts available for a 42 * particular rendering system. This is a virtual object with 43 * implementations being specific to particular rendering systems. To 44 * create an implementation of a #PangoFontMap, the rendering-system 45 * specific code should allocate a larger structure that contains a nested 46 * #PangoFontMap, fill in the <structfield>klass</structfield> member of the nested #PangoFontMap with a 47 * pointer to a appropriate #PangoFontMapClass, then call 48 * pango_font_map_init() on the structure. 49 * 50 * The #PangoFontMap structure contains one member which the implementation 51 * fills in. 52 */ 53 public class PgFontMap : ObjectG 54 { 55 /** the main Gtk struct */ 56 protected PangoFontMap* pangoFontMap; 57 58 /** Get the main Gtk struct */ 59 public PangoFontMap* getPgFontMapStruct(bool transferOwnership = false) 60 { 61 if (transferOwnership) 62 ownedRef = false; 63 return pangoFontMap; 64 } 65 66 /** the main Gtk struct as a void* */ 67 protected override void* getStruct() 68 { 69 return cast(void*)pangoFontMap; 70 } 71 72 protected override void setStruct(GObject* obj) 73 { 74 pangoFontMap = cast(PangoFontMap*)obj; 75 super.setStruct(obj); 76 } 77 78 /** 79 * Sets our main struct and passes it to the parent class. 80 */ 81 public this (PangoFontMap* pangoFontMap, bool ownedRef = false) 82 { 83 this.pangoFontMap = pangoFontMap; 84 super(cast(GObject*)pangoFontMap, ownedRef); 85 } 86 87 88 /** */ 89 public static GType getType() 90 { 91 return pango_font_map_get_type(); 92 } 93 94 /** 95 * Forces a change in the context, which will cause any #PangoContext 96 * using this fontmap to change. 97 * 98 * This function is only useful when implementing a new backend 99 * for Pango, something applications won't do. Backends should 100 * call this function if they have attached extra data to the context 101 * and such data is changed. 102 * 103 * Since: 1.34 104 */ 105 public void changed() 106 { 107 pango_font_map_changed(pangoFontMap); 108 } 109 110 /** 111 * Creates a #PangoContext connected to @fontmap. This is equivalent 112 * to pango_context_new() followed by pango_context_set_font_map(). 113 * 114 * If you are using Pango as part of a higher-level system, 115 * that system may have it's own way of create a #PangoContext. 116 * For instance, the GTK+ toolkit has, among others, 117 * gdk_pango_context_get_for_screen(), and 118 * gtk_widget_get_pango_context(). Use those instead. 119 * 120 * Returns: the newly allocated #PangoContext, 121 * which should be freed with g_object_unref(). 122 * 123 * Since: 1.22 124 */ 125 public PgContext createContext() 126 { 127 auto p = pango_font_map_create_context(pangoFontMap); 128 129 if(p is null) 130 { 131 return null; 132 } 133 134 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true); 135 } 136 137 /** 138 * Returns the current serial number of @fontmap. The serial number is 139 * initialized to an small number larger than zero when a new fontmap 140 * is created and is increased whenever the fontmap is changed. It may 141 * wrap, but will never have the value 0. Since it can wrap, never compare 142 * it with "less than", always use "not equals". 143 * 144 * The fontmap can only be changed using backend-specific API, like changing 145 * fontmap resolution. 146 * 147 * This can be used to automatically detect changes to a #PangoFontMap, like 148 * in #PangoContext. 149 * 150 * Returns: The current serial number of @fontmap. 151 * 152 * Since: 1.32.4 153 */ 154 public uint getSerial() 155 { 156 return pango_font_map_get_serial(pangoFontMap); 157 } 158 159 /** 160 * Returns the render ID for shape engines for this fontmap. 161 * See the <structfield>render_type</structfield> field of 162 * #PangoEngineInfo. 163 * 164 * Returns: the ID string for shape engines for 165 * this fontmap. Owned by Pango, should not be modified 166 * or freed. 167 * 168 * Since: 1.4 169 */ 170 public string getShapeEngineType() 171 { 172 return Str.toString(pango_font_map_get_shape_engine_type(pangoFontMap)); 173 } 174 175 /** 176 * List all families for a fontmap. 177 * 178 * Params: 179 * families = location to store a pointer to an array of #PangoFontFamily *. 180 * This array should be freed with g_free(). 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 }