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.PgCairoFontMap; 26 27 private import cairo.ScaledFont; 28 private import glib.ConstructionException; 29 private import gobject.ObjectG; 30 private import gtkc.pango; 31 public import gtkc.pangotypes; 32 private import pango.PgFontMap; 33 34 35 /** 36 * #PangoCairoFontMap is an interface exported by font maps for 37 * use with Cairo. The actual type of the font map will depend 38 * on the particular font technology Cairo was compiled to use. 39 * 40 * Since: 1.10 41 */ 42 public class PgCairoFontMap : PgFontMap 43 { 44 /** the main Gtk struct */ 45 protected PangoCairoFontMap* pangoCairoFontMap; 46 47 /** Get the main Gtk struct */ 48 public PangoCairoFontMap* getPgCairoFontMapStruct(bool transferOwnership = false) 49 { 50 if (transferOwnership) 51 ownedRef = false; 52 return pangoCairoFontMap; 53 } 54 55 /** the main Gtk struct as a void* */ 56 protected override void* getStruct() 57 { 58 return cast(void*)pangoCairoFontMap; 59 } 60 61 protected override void setStruct(GObject* obj) 62 { 63 pangoCairoFontMap = cast(PangoCairoFontMap*)obj; 64 super.setStruct(obj); 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (PangoCairoFontMap* pangoCairoFontMap, bool ownedRef = false) 71 { 72 this.pangoCairoFontMap = pangoCairoFontMap; 73 super(cast(PangoFontMap*)pangoCairoFontMap, ownedRef); 74 } 75 76 77 /** 78 * Gets a default #PangoCairoFontMap to use with Cairo. 79 * 80 * Note that the type of the returned object will depend 81 * on the particular font backend Cairo was compiled to use; 82 * You generally should only use the #PangoFontMap and 83 * #PangoCairoFontMap interfaces on the returned object. 84 * 85 * The default Cairo fontmap can be changed by using 86 * pango_cairo_font_map_set_default(). This can be used to 87 * change the Cairo font backend that the default fontmap 88 * uses for example. 89 * 90 * Note that since Pango 1.32.6, the default fontmap is per-thread. 91 * Each thread gets its own default fontmap. In this way, 92 * PangoCairo can be used safely from multiple threads. 93 * 94 * Returns: the default PangoCairo fontmap 95 * for the current thread. This object is owned by Pango and must not be freed. 96 * 97 * Since: 1.10 98 */ 99 public static PgFontMap getDefault() 100 { 101 auto p = pango_cairo_font_map_get_default(); 102 103 if(p is null) 104 { 105 return null; 106 } 107 108 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p); 109 } 110 111 /** 112 * Creates a new #PangoCairoFontMap object; a fontmap is used 113 * to cache information about available fonts, and holds 114 * certain global parameters such as the resolution. 115 * In most cases, you can use pango_cairo_font_map_get_default() 116 * instead. 117 * 118 * Note that the type of the returned object will depend 119 * on the particular font backend Cairo was compiled to use; 120 * You generally should only use the #PangoFontMap and 121 * #PangoCairoFontMap interfaces on the returned object. 122 * 123 * You can override the type of backend returned by using an 124 * environment variable %PANGOCAIRO_BACKEND. Supported types, 125 * based on your build, are fc (fontconfig), win32, and coretext. 126 * If requested type is not available, NULL is returned. Ie. 127 * this is only useful for testing, when at least two backends 128 * are compiled in. 129 * 130 * Returns: the newly allocated #PangoFontMap, 131 * which should be freed with g_object_unref(). 132 * 133 * Since: 1.10 134 * 135 * Throws: ConstructionException GTK+ fails to create the object. 136 */ 137 public this() 138 { 139 auto p = pango_cairo_font_map_new(); 140 141 if(p is null) 142 { 143 throw new ConstructionException("null returned by new"); 144 } 145 146 this(cast(PangoCairoFontMap*) p, true); 147 } 148 149 /** 150 * Creates a new #PangoCairoFontMap object of the type suitable 151 * to be used with cairo font backend of type @fonttype. 152 * 153 * In most cases one should simply use @pango_cairo_font_map_new(), 154 * or in fact in most of those cases, just use 155 * @pango_cairo_font_map_get_default(). 156 * 157 * Params: 158 * fonttype = desired #cairo_font_type_t 159 * 160 * Returns: the newly allocated 161 * #PangoFontMap of suitable type which should be freed 162 * with g_object_unref(), or %NULL if the requested 163 * cairo font backend is not supported / compiled in. 164 * 165 * Since: 1.18 166 * 167 * Throws: ConstructionException GTK+ fails to create the object. 168 */ 169 public this(cairo_font_type_t fonttype) 170 { 171 auto p = pango_cairo_font_map_new_for_font_type(fonttype); 172 173 if(p is null) 174 { 175 throw new ConstructionException("null returned by new_for_font_type"); 176 } 177 178 this(cast(PangoCairoFontMap*) p, true); 179 } 180 181 /** 182 * Gets the type of Cairo font backend that @fontmap uses. 183 * 184 * Returns: the #cairo_font_type_t cairo font backend type 185 * 186 * Since: 1.18 187 */ 188 public cairo_font_type_t getFontType() 189 { 190 return pango_cairo_font_map_get_font_type(cast(PangoCairoFontMap*)pangoCairoFontMap); 191 } 192 193 /** 194 * Gets the resolution for the fontmap. See pango_cairo_font_map_set_resolution() 195 * 196 * Returns: the resolution in "dots per inch" 197 * 198 * Since: 1.10 199 */ 200 public double getResolution() 201 { 202 return pango_cairo_font_map_get_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap); 203 } 204 205 /** 206 * Sets a default #PangoCairoFontMap to use with Cairo. 207 * 208 * This can be used to change the Cairo font backend that the 209 * default fontmap uses for example. The old default font map 210 * is unreffed and the new font map referenced. 211 * 212 * Note that since Pango 1.32.6, the default fontmap is per-thread. 213 * This function only changes the default fontmap for 214 * the current thread. Default fontmaps of exisiting threads 215 * are not changed. Default fontmaps of any new threads will 216 * still be created using pango_cairo_font_map_new(). 217 * 218 * A value of %NULL for @fontmap will cause the current default 219 * font map to be released and a new default font 220 * map to be created on demand, using pango_cairo_font_map_new(). 221 * 222 * Since: 1.22 223 */ 224 public void setDefault() 225 { 226 pango_cairo_font_map_set_default(cast(PangoCairoFontMap*)pangoCairoFontMap); 227 } 228 229 /** 230 * Sets the resolution for the fontmap. This is a scale factor between 231 * points specified in a #PangoFontDescription and Cairo units. The 232 * default value is 96, meaning that a 10 point font will be 13 233 * units high. (10 * 96. / 72. = 13.3). 234 * 235 * Params: 236 * dpi = the resolution in "dots per inch". (Physical inches aren't actually 237 * involved; the terminology is conventional.) 238 * 239 * Since: 1.10 240 */ 241 public void setResolution(double dpi) 242 { 243 pango_cairo_font_map_set_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap, dpi); 244 } 245 246 /** 247 * Gets the #cairo_scaled_font_t used by @font. 248 * The scaled font can be referenced and kept using 249 * cairo_scaled_font_reference(). 250 * 251 * Returns: the #cairo_scaled_font_t used by @font, 252 * or %NULL if @font is %NULL. 253 * 254 * Since: 1.18 255 */ 256 public ScaledFont getScaledFont() 257 { 258 auto p = pango_cairo_font_get_scaled_font(cast(PangoCairoFont*)pangoCairoFontMap); 259 260 if(p is null) 261 { 262 return null; 263 } 264 265 return new ScaledFont(cast(cairo_scaled_font_t*) p); 266 } 267 }