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