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