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 * Description 88 * Pango supports a flexible architecture where a 89 * particular rendering architecture can supply an 90 * implementation of fonts. The PangoFont structure 91 * represents an abstract rendering-system-independent font. 92 * Pango provides routines to list available fonts, and 93 * to load a font of a given description. 94 */ 95 public class PgFontMap : ObjectG 96 { 97 98 /** the main Gtk struct */ 99 protected PangoFontMap* pangoFontMap; 100 101 102 public PangoFontMap* getPgFontMapStruct() 103 { 104 return pangoFontMap; 105 } 106 107 108 /** the main Gtk struct as a void* */ 109 protected override void* getStruct() 110 { 111 return cast(void*)pangoFontMap; 112 } 113 114 /** 115 * Sets our main struct and passes it to the parent class 116 */ 117 public this (PangoFontMap* pangoFontMap) 118 { 119 super(cast(GObject*)pangoFontMap); 120 this.pangoFontMap = pangoFontMap; 121 } 122 123 protected override void setStruct(GObject* obj) 124 { 125 super.setStruct(obj); 126 pangoFontMap = cast(PangoFontMap*)obj; 127 } 128 129 /** 130 */ 131 132 /** 133 * Creates a PangoContext connected to fontmap. This is equivalent 134 * to pango_context_new() followed by pango_context_set_font_map(). 135 * If you are using Pango as part of a higher-level system, 136 * that system may have it's own way of create a PangoContext. 137 * For instance, the GTK+ toolkit has, among others, 138 * gdk_pango_context_get_for_screen(), and 139 * gtk_widget_get_pango_context(). Use those instead. 140 * Since 1.22 141 * Returns: the newly allocated PangoContext, which should be freed with g_object_unref(). 142 */ 143 public PgContext createContext() 144 { 145 // PangoContext * pango_font_map_create_context (PangoFontMap *fontmap); 146 auto p = pango_font_map_create_context(pangoFontMap); 147 148 if(p is null) 149 { 150 return null; 151 } 152 153 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p); 154 } 155 156 /** 157 * Load the font in the fontmap that is the closest match for desc. 158 * Params: 159 * context = the PangoContext the font will be used with 160 * desc = a PangoFontDescription describing the font to load 161 * Returns: the font loaded, or NULL if no font matched. 162 */ 163 public PgFont loadFont(PgContext context, PgFontDescription desc) 164 { 165 // PangoFont * pango_font_map_load_font (PangoFontMap *fontmap, PangoContext *context, const PangoFontDescription *desc); 166 auto p = pango_font_map_load_font(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct()); 167 168 if(p is null) 169 { 170 return null; 171 } 172 173 return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p); 174 } 175 176 /** 177 * Load a set of fonts in the fontmap that can be used to render 178 * a font matching desc. 179 * Params: 180 * context = the PangoContext the font will be used with 181 * desc = a PangoFontDescription describing the font to load 182 * language = a PangoLanguage the fonts will be used for 183 * Returns: the fontset, or NULL if no font matched. 184 */ 185 public PgFontset loadFontset(PgContext context, PgFontDescription desc, PgLanguage language) 186 { 187 // PangoFontset * pango_font_map_load_fontset (PangoFontMap *fontmap, PangoContext *context, const PangoFontDescription *desc, PangoLanguage *language); 188 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()); 189 190 if(p is null) 191 { 192 return null; 193 } 194 195 return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) p); 196 } 197 198 /** 199 * List all families for a fontmap. 200 * Params: 201 * families = location to store a pointer to an array of PangoFontFamily *. 202 * This array should be freed with g_free(). 203 */ 204 public void listFamilies(out PgFontFamily[] families) 205 { 206 // void pango_font_map_list_families (PangoFontMap *fontmap, PangoFontFamily ***families, int *n_families); 207 PangoFontFamily** outfamilies = null; 208 int nFamilies; 209 210 pango_font_map_list_families(pangoFontMap, &outfamilies, &nFamilies); 211 212 213 families = new PgFontFamily[nFamilies]; 214 for(int i = 0; i < nFamilies; i++) 215 { 216 families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]); 217 } 218 } 219 220 /** 221 * Returns the render ID for shape engines for this fontmap. 222 * See the render_type field of 223 * PangoEngineInfo. 224 * Since 1.4 225 * Returns: the ID string for shape engines for this fontmap. Owned by Pango, should not be modified or freed. 226 */ 227 public string getShapeEngineType() 228 { 229 // const char * pango_font_map_get_shape_engine_type (PangoFontMap *fontmap); 230 return Str.toString(pango_font_map_get_shape_engine_type(pangoFontMap)); 231 } 232 }