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 = pango-Cairo-Rendering.html 27 * outPack = pango 28 * outFile = PgCairoFontMap 29 * strct = PangoCairoFontMap 30 * realStrct= 31 * ctorStrct=PangoFontMap 32 * clss = PgCairoFontMap 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = PangoFontMap 38 * implements: 39 * prefixes: 40 * - pango_cairo_font_map_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - pango.PgFontMap 48 * - pango.PgContext 49 * structWrap: 50 * - PangoContext* -> PgContext 51 * - PangoFontMap* -> PgFontMap 52 * module aliases: 53 * local aliases: 54 * overrides: 55 * - createContext 56 */ 57 58 module pango.PgCairoFontMap; 59 60 public import gtkc.pangotypes; 61 62 private import gtkc.pango; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import glib.Str; 67 private import pango.PgFontMap; 68 private import pango.PgContext; 69 70 71 private import pango.PgFontMap; 72 73 /** 74 * The Cairo library is a 75 * vector graphics library with a powerful rendering model. It has such 76 * features as anti-aliased primitives, alpha-compositing, and 77 * gradients. Multiple backends for Cairo are available, to allow 78 * rendering to images, to PDF files, and to the screen on X and on other 79 * windowing systems. The functions in this section allow using Pango 80 * to render to Cairo surfaces. 81 * 82 * Using Pango with Cairo is straightforward. A PangoContext created 83 * with pango_cairo_font_map_create_context() can be used on any 84 * Cairo context (cairo_t), but needs to be updated to match the 85 * current transformation matrix and target surface of the Cairo context 86 * using pango_cairo_update_context(). The convenience functions 87 * pango_cairo_create_layout() and pango_cairo_update_layout() handle 88 * the common case where the program doesn't need to manipulate the 89 * properties of the PangoContext. 90 * 91 * When you get the metrics of a layout or of a piece of a layout using 92 * functions such as pango_layout_get_extents(), the reported metrics 93 * are in user-space coordinates. If a piece of text is 10 units long, 94 * and you call cairo_scale (cr, 2.0), it still is more-or-less 10 95 * units long. However, the results will be affected by hinting 96 * (that is, the process of adjusting the text to look good on the 97 * pixel grid), so you shouldn't assume they are completely independent 98 * of the current transformation matrix. Note that the basic metrics 99 * functions in Pango report results in integer Pango units. To get 100 * to the floating point units used in Cairo divide by PANGO_SCALE. 101 * 102 * $(DDOC_COMMENT example) 103 * 104 * Figure 2. Output of Example 1, “Using Pango with Cairo” 105 */ 106 public class PgCairoFontMap : PgFontMap 107 { 108 109 /** the main Gtk struct */ 110 protected PangoCairoFontMap* pangoCairoFontMap; 111 112 113 /** Get the main Gtk struct */ 114 public PangoCairoFontMap* getPgCairoFontMapStruct() 115 { 116 return pangoCairoFontMap; 117 } 118 119 120 /** the main Gtk struct as a void* */ 121 protected override void* getStruct() 122 { 123 return cast(void*)pangoCairoFontMap; 124 } 125 126 /** 127 * Sets our main struct and passes it to the parent class 128 */ 129 public this (PangoCairoFontMap* pangoCairoFontMap) 130 { 131 super(cast(PangoFontMap*)pangoCairoFontMap); 132 this.pangoCairoFontMap = pangoCairoFontMap; 133 } 134 135 protected override void setStruct(GObject* obj) 136 { 137 super.setStruct(obj); 138 pangoCairoFontMap = cast(PangoCairoFontMap*)obj; 139 } 140 141 /** 142 */ 143 144 /** 145 * Gets a default PangoCairoFontMap to use with Cairo. 146 * Note that the type of the returned object will depend 147 * on the particular font backend Cairo was compiled to use; 148 * You generally should only use the PangoFontMap and 149 * PangoCairoFontMap interfaces on the returned object. 150 * The default Cairo fontmap can be changed by using 151 * pango_cairo_font_map_set_default(). This can be used to 152 * change the Cairo font backend that the default fontmap 153 * uses for example. 154 * Note that since Pango 1.32.6, the default fontmap is per-thread. 155 * Each thread gets its own default fontmap. In this way, 156 * PangoCairo can be used safely from multiple threads. 157 * Since 1.10 158 * Returns: the default PangoCairo fontmap for the current thread. This object is owned by Pango and must not be freed. [transfer none] 159 */ 160 public static PgFontMap getDefault() 161 { 162 // PangoFontMap * pango_cairo_font_map_get_default (void); 163 auto p = pango_cairo_font_map_get_default(); 164 165 if(p is null) 166 { 167 return null; 168 } 169 170 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p); 171 } 172 173 /** 174 * Sets a default PangoCairoFontMap to use with Cairo. 175 * This can be used to change the Cairo font backend that the 176 * default fontmap uses for example. The old default font map 177 * is unreffed and the new font map referenced. 178 * Note that since Pango 1.32.6, the default fontmap is per-thread. 179 * This function only changes the default fontmap for 180 * the current thread. Default fontmaps of exisiting threads 181 * are not changed. Default fontmaps of any new threads will 182 * still be created using pango_cairo_font_map_new(). 183 * A value of NULL for fontmap will cause the current default 184 * font map to be released and a new default font 185 * map to be created on demand, using pango_cairo_font_map_new(). 186 * Since 1.22 187 */ 188 public void setDefault() 189 { 190 // void pango_cairo_font_map_set_default (PangoCairoFontMap *fontmap); 191 pango_cairo_font_map_set_default(pangoCairoFontMap); 192 } 193 194 /** 195 * Creates a new PangoCairoFontMap object; a fontmap is used 196 * to cache information about available fonts, and holds 197 * certain global parameters such as the resolution. 198 * In most cases, you can use pango_cairo_font_map_get_default() 199 * instead. 200 * Note that the type of the returned object will depend 201 * on the particular font backend Cairo was compiled to use; 202 * You generally should only use the PangoFontMap and 203 * PangoCairoFontMap interfaces on the returned object. 204 * Since 1.10 205 * Throws: ConstructionException GTK+ fails to create the object. 206 */ 207 public this () 208 { 209 // PangoFontMap * pango_cairo_font_map_new (void); 210 auto p = pango_cairo_font_map_new(); 211 if(p is null) 212 { 213 throw new ConstructionException("null returned by pango_cairo_font_map_new()"); 214 } 215 this(cast(PangoCairoFontMap*) p); 216 } 217 218 /** 219 * Creates a new PangoCairoFontMap object of the type suitable 220 * to be used with cairo font backend of type fonttype. 221 * In most cases one should simply use pango_cairo_font_map_new(), 222 * or in fact in most of those cases, just use 223 * pango_cairo_font_map_get_default(). 224 * Since 1.18 225 * Params: 226 * fonttype = desired cairo_font_type_t 227 * Throws: ConstructionException GTK+ fails to create the object. 228 */ 229 public this (cairo_font_type_t fonttype) 230 { 231 // PangoFontMap * pango_cairo_font_map_new_for_font_type (cairo_font_type_t fonttype); 232 auto p = pango_cairo_font_map_new_for_font_type(fonttype); 233 if(p is null) 234 { 235 throw new ConstructionException("null returned by pango_cairo_font_map_new_for_font_type(fonttype)"); 236 } 237 this(cast(PangoCairoFontMap*) p); 238 } 239 240 /** 241 * Gets the type of Cairo font backend that fontmap uses. 242 * Since 1.18 243 * Returns: the cairo_font_type_t cairo font backend type 244 */ 245 public cairo_font_type_t getFontType() 246 { 247 // cairo_font_type_t pango_cairo_font_map_get_font_type (PangoCairoFontMap *fontmap); 248 return pango_cairo_font_map_get_font_type(pangoCairoFontMap); 249 } 250 251 /** 252 * Sets the resolution for the fontmap. This is a scale factor between 253 * points specified in a PangoFontDescription and Cairo units. The 254 * default value is 96, meaning that a 10 point font will be 13 255 * units high. (10 * 96. / 72. = 13.3). 256 * Since 1.10 257 * Params: 258 * dpi = the resolution in "dots per inch". (Physical inches aren't actually 259 * involved; the terminology is conventional.) 260 */ 261 public void setResolution(double dpi) 262 { 263 // void pango_cairo_font_map_set_resolution (PangoCairoFontMap *fontmap, double dpi); 264 pango_cairo_font_map_set_resolution(pangoCairoFontMap, dpi); 265 } 266 267 /** 268 * Gets the resolution for the fontmap. See pango_cairo_font_map_set_resolution() 269 * Since 1.10 270 * Returns: the resolution in "dots per inch" 271 */ 272 public double getResolution() 273 { 274 // double pango_cairo_font_map_get_resolution (PangoCairoFontMap *fontmap); 275 return pango_cairo_font_map_get_resolution(pangoCairoFontMap); 276 } 277 278 /** 279 * Warning 280 * pango_cairo_font_map_create_context has been deprecated since version 1.22 and should not be used in newly-written code. Use pango_font_map_create_context() instead. 281 * Create a PangoContext for the given fontmap. 282 * Since 1.10 283 * Returns: the newly created context; free with g_object_unref(). 284 */ 285 public override PgContext createContext() 286 { 287 // PangoContext * pango_cairo_font_map_create_context (PangoCairoFontMap *fontmap); 288 auto p = pango_cairo_font_map_create_context(pangoCairoFontMap); 289 290 if(p is null) 291 { 292 return null; 293 } 294 295 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p); 296 } 297 }