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