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