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-Fonts.html 27 * outPack = pango 28 * outFile = PgFont 29 * strct = PangoFont 30 * realStrct= 31 * ctorStrct= 32 * clss = PgFont 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = GObject 38 * implements: 39 * prefixes: 40 * - pango_font_ 41 * omit structs: 42 * omit prefixes: 43 * - pango_font_description_ 44 * - pango_font_descriptions_ 45 * - pango_font_metrics_ 46 * - pango_font_family_ 47 * - pango_font_face_ 48 * - pango_font_map_ 49 * - pango_fontset_ 50 * - pango_fontset_simple_ 51 * omit code: 52 * omit signals: 53 * imports: 54 * - pango.PgEngineShape 55 * - pango.PgFontDescription 56 * - pango.PgCoverage 57 * - pango.PgFontMetrics 58 * - pango.PgFontMap 59 * - pango.PgLanguage 60 * structWrap: 61 * - PangoCoverage* -> PgCoverage 62 * - PangoEngineShape* -> PgEngineShape 63 * - PangoFontDescription* -> PgFontDescription 64 * - PangoFontMap* -> PgFontMap 65 * - PangoFontMetrics* -> PgFontMetrics 66 * - PangoLanguage* -> PgLanguage 67 * module aliases: 68 * local aliases: 69 * overrides: 70 */ 71 72 module pango.PgFont; 73 74 public import gtkc.pangotypes; 75 76 private import gtkc.pango; 77 private import glib.ConstructionException; 78 private import gobject.ObjectG; 79 80 81 private import pango.PgEngineShape; 82 private import pango.PgFontDescription; 83 private import pango.PgCoverage; 84 private import pango.PgFontMetrics; 85 private import pango.PgFontMap; 86 private import pango.PgLanguage; 87 88 89 90 private import gobject.ObjectG; 91 92 /** 93 * Pango supports a flexible architecture where a 94 * particular rendering architecture can supply an 95 * implementation of fonts. The PangoFont structure 96 * represents an abstract rendering-system-independent font. 97 * Pango provides routines to list available fonts, and 98 * to load a font of a given description. 99 */ 100 public class PgFont : ObjectG 101 { 102 103 /** the main Gtk struct */ 104 protected PangoFont* pangoFont; 105 106 107 public PangoFont* getPgFontStruct() 108 { 109 return pangoFont; 110 } 111 112 113 /** the main Gtk struct as a void* */ 114 protected override void* getStruct() 115 { 116 return cast(void*)pangoFont; 117 } 118 119 /** 120 * Sets our main struct and passes it to the parent class 121 */ 122 public this (PangoFont* pangoFont) 123 { 124 super(cast(GObject*)pangoFont); 125 this.pangoFont = pangoFont; 126 } 127 128 protected override void setStruct(GObject* obj) 129 { 130 super.setStruct(obj); 131 pangoFont = cast(PangoFont*)obj; 132 } 133 134 /** 135 */ 136 137 /** 138 * Finds the best matching shaper for a font for a particular 139 * language tag and character point. 140 * Params: 141 * language = the language tag 142 * ch = a Unicode character. 143 * Returns: the best matching shaper. 144 */ 145 public PgEngineShape findShaper(PgLanguage language, uint ch) 146 { 147 // PangoEngineShape * pango_font_find_shaper (PangoFont *font, PangoLanguage *language, guint32 ch); 148 auto p = pango_font_find_shaper(pangoFont, (language is null) ? null : language.getPgLanguageStruct(), ch); 149 150 if(p is null) 151 { 152 return null; 153 } 154 155 return ObjectG.getDObject!(PgEngineShape)(cast(PangoEngineShape*) p); 156 } 157 158 /** 159 * Returns a description of the font, with font size set in points. 160 * Use pango_font_describe_with_absolute_size() if you want the font 161 * size in device units. 162 * Returns: a newly-allocated PangoFontDescription object. 163 */ 164 public PgFontDescription describe() 165 { 166 // PangoFontDescription * pango_font_describe (PangoFont *font); 167 auto p = pango_font_describe(pangoFont); 168 169 if(p is null) 170 { 171 return null; 172 } 173 174 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 175 } 176 177 /** 178 * Returns a description of the font, with absolute font size set 179 * (in device units). Use pango_font_describe() if you want the font 180 * size in points. 181 * Since 1.14 182 * Returns: a newly-allocated PangoFontDescription object. 183 */ 184 public PgFontDescription describeWithAbsoluteSize() 185 { 186 // PangoFontDescription * pango_font_describe_with_absolute_size (PangoFont *font); 187 auto p = pango_font_describe_with_absolute_size(pangoFont); 188 189 if(p is null) 190 { 191 return null; 192 } 193 194 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 195 } 196 197 /** 198 * Computes the coverage map for a given font and language tag. 199 * Params: 200 * language = the language tag 201 * Returns: a newly-allocated PangoCoverage object. [transfer full] 202 */ 203 public PgCoverage getCoverage(PgLanguage language) 204 { 205 // PangoCoverage * pango_font_get_coverage (PangoFont *font, PangoLanguage *language); 206 auto p = pango_font_get_coverage(pangoFont, (language is null) ? null : language.getPgLanguageStruct()); 207 208 if(p is null) 209 { 210 return null; 211 } 212 213 return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p); 214 } 215 216 /** 217 * Gets the logical and ink extents of a glyph within a font. The 218 * coordinate system for each rectangle has its origin at the 219 * base line and horizontal origin of the character with increasing 220 * coordinates extending to the right and down. The macros PANGO_ASCENT(), 221 * PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert 222 * from the extents rectangle to more traditional font metrics. The units 223 * of the rectangles are in 1/PANGO_SCALE of a device unit. 224 * If font is NULL, this function gracefully sets some sane values in the 225 * output variables and returns. 226 * Params: 227 * glyph = the glyph index 228 * inkRect = rectangle used to store the extents of the glyph 229 * as drawn or NULL to indicate that the result is not needed. [out][allow-none] 230 * logicalRect = rectangle used to store the logical extents of 231 * the glyph or NULL to indicate that the result is not needed. [out][allow-none] 232 */ 233 public void getGlyphExtents(PangoGlyph glyph, PangoRectangle* inkRect, PangoRectangle* logicalRect) 234 { 235 // void pango_font_get_glyph_extents (PangoFont *font, PangoGlyph glyph, PangoRectangle *ink_rect, PangoRectangle *logical_rect); 236 pango_font_get_glyph_extents(pangoFont, glyph, inkRect, logicalRect); 237 } 238 239 /** 240 * Gets overall metric information for a font. Since the metrics may be 241 * substantially different for different scripts, a language tag can 242 * be provided to indicate that the metrics should be retrieved that 243 * correspond to the script(s) used by that language. 244 * If font is NULL, this function gracefully sets some sane values in the 245 * output variables and returns. 246 * Params: 247 * language = language tag used to determine which script to get the metrics 248 * for, or NULL to indicate to get the metrics for the entire font. [allow-none] 249 * Returns: a PangoFontMetrics object. The caller must call pango_font_metrics_unref() when finished using the object. 250 */ 251 public PgFontMetrics getMetrics(PgLanguage language) 252 { 253 // PangoFontMetrics * pango_font_get_metrics (PangoFont *font, PangoLanguage *language); 254 auto p = pango_font_get_metrics(pangoFont, (language is null) ? null : language.getPgLanguageStruct()); 255 256 if(p is null) 257 { 258 return null; 259 } 260 261 return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p); 262 } 263 264 /** 265 * Gets the font map for which the font was created. 266 * Note that the font maintains a weak reference 267 * to the font map, so if all references to font map are dropped, the font 268 * map will be finalized even if there are fonts created with the font 269 * map that are still alive. In that case this function will return NULL. 270 * It is the responsibility of the user to ensure that the font map is kept 271 * alive. In most uses this is not an issue as a PangoContext holds 272 * a reference to the font map. 273 * Since 1.10 274 * Returns: the PangoFontMap for the font, or NULL if font is NULL. [transfer none] 275 */ 276 public PgFontMap getFontMap() 277 { 278 // PangoFontMap * pango_font_get_font_map (PangoFont *font); 279 auto p = pango_font_get_font_map(pangoFont); 280 281 if(p is null) 282 { 283 return null; 284 } 285 286 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p); 287 } 288 }