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