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.PgFont; 26 27 private import gobject.ObjectG; 28 private import gtkc.pango; 29 public import gtkc.pangotypes; 30 private import pango.PgCoverage; 31 private import pango.PgEngineShape; 32 private import pango.PgFontDescription; 33 private import pango.PgFontMap; 34 private import pango.PgFontMetrics; 35 private import pango.PgLanguage; 36 37 38 /** 39 * The #PangoFont structure is used to represent 40 * a font in a rendering-system-independent matter. 41 * To create an implementation of a #PangoFont, 42 * the rendering-system specific code should allocate 43 * a larger structure that contains a nested 44 * #PangoFont, fill in the <structfield>klass</structfield> member of 45 * the nested #PangoFont with a pointer to 46 * a appropriate #PangoFontClass, then call 47 * pango_font_init() on the structure. 48 * 49 * The #PangoFont structure contains one member 50 * which the implementation fills in. 51 */ 52 public class PgFont : ObjectG 53 { 54 /** the main Gtk struct */ 55 protected PangoFont* pangoFont; 56 57 /** Get the main Gtk struct */ 58 public PangoFont* getPgFontStruct() 59 { 60 return pangoFont; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)pangoFont; 67 } 68 69 protected override void setStruct(GObject* obj) 70 { 71 pangoFont = cast(PangoFont*)obj; 72 super.setStruct(obj); 73 } 74 75 /** 76 * Sets our main struct and passes it to the parent class. 77 */ 78 public this (PangoFont* pangoFont, bool ownedRef = false) 79 { 80 this.pangoFont = pangoFont; 81 super(cast(GObject*)pangoFont, ownedRef); 82 } 83 84 85 /** */ 86 public static GType getType() 87 { 88 return pango_font_get_type(); 89 } 90 91 /** 92 * Frees an array of font descriptions. 93 * 94 * Params: 95 * descs = a pointer 96 * to an array of #PangoFontDescription, may be %NULL 97 * nDescs = number of font descriptions in @descs 98 */ 99 public static void descriptionsFree(PgFontDescription[] descs) 100 { 101 PangoFontDescription*[] descsArray = new PangoFontDescription*[descs.length]; 102 for ( int i = 0; i < descs.length; i++ ) 103 { 104 descsArray[i] = descs[i].getPgFontDescriptionStruct(); 105 } 106 107 pango_font_descriptions_free(descsArray.ptr, cast(int)descs.length); 108 } 109 110 /** 111 * Returns a description of the font, with font size set in points. 112 * Use pango_font_describe_with_absolute_size() if you want the font 113 * size in device units. 114 * 115 * Return: a newly-allocated #PangoFontDescription object. 116 */ 117 public PgFontDescription describe() 118 { 119 auto p = pango_font_describe(pangoFont); 120 121 if(p is null) 122 { 123 return null; 124 } 125 126 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p, true); 127 } 128 129 /** 130 * Returns a description of the font, with absolute font size set 131 * (in device units). Use pango_font_describe() if you want the font 132 * size in points. 133 * 134 * Return: a newly-allocated #PangoFontDescription object. 135 * 136 * Since: 1.14 137 */ 138 public PgFontDescription describeWithAbsoluteSize() 139 { 140 auto p = pango_font_describe_with_absolute_size(pangoFont); 141 142 if(p is null) 143 { 144 return null; 145 } 146 147 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p, true); 148 } 149 150 /** 151 * Finds the best matching shaper for a font for a particular 152 * language tag and character point. 153 * 154 * Params: 155 * language = the language tag 156 * ch = a Unicode character. 157 * 158 * Return: the best matching shaper. 159 */ 160 public PgEngineShape findShaper(PgLanguage language, uint ch) 161 { 162 auto p = pango_font_find_shaper(pangoFont, (language is null) ? null : language.getPgLanguageStruct(), ch); 163 164 if(p is null) 165 { 166 return null; 167 } 168 169 return ObjectG.getDObject!(PgEngineShape)(cast(PangoEngineShape*) p); 170 } 171 172 /** 173 * Computes the coverage map for a given font and language tag. 174 * 175 * Params: 176 * language = the language tag 177 * 178 * Return: a newly-allocated #PangoCoverage 179 * object. 180 */ 181 public PgCoverage getCoverage(PgLanguage language) 182 { 183 auto p = pango_font_get_coverage(pangoFont, (language is null) ? null : language.getPgLanguageStruct()); 184 185 if(p is null) 186 { 187 return null; 188 } 189 190 return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p, true); 191 } 192 193 /** 194 * Gets the font map for which the font was created. 195 * 196 * Note that the font maintains a <firstterm>weak</firstterm> reference 197 * to the font map, so if all references to font map are dropped, the font 198 * map will be finalized even if there are fonts created with the font 199 * map that are still alive. In that case this function will return %NULL. 200 * It is the responsibility of the user to ensure that the font map is kept 201 * alive. In most uses this is not an issue as a #PangoContext holds 202 * a reference to the font map. 203 * 204 * Return: the #PangoFontMap for the 205 * font, or %NULL if @font is %NULL. 206 * 207 * Since: 1.10 208 */ 209 public PgFontMap getFontMap() 210 { 211 auto p = pango_font_get_font_map(pangoFont); 212 213 if(p is null) 214 { 215 return null; 216 } 217 218 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p); 219 } 220 221 /** 222 * Gets the logical and ink extents of a glyph within a font. The 223 * coordinate system for each rectangle has its origin at the 224 * base line and horizontal origin of the character with increasing 225 * coordinates extending to the right and down. The macros PANGO_ASCENT(), 226 * PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert 227 * from the extents rectangle to more traditional font metrics. The units 228 * of the rectangles are in 1/PANGO_SCALE of a device unit. 229 * 230 * If @font is %NULL, this function gracefully sets some sane values in the 231 * output variables and returns. 232 * 233 * Params: 234 * glyph = the glyph index 235 * inkRect = rectangle used to store the extents of the glyph 236 * as drawn or %NULL to indicate that the result is not needed. 237 * logicalRect = rectangle used to store the logical extents of 238 * the glyph or %NULL to indicate that the result is not needed. 239 */ 240 public void getGlyphExtents(PangoGlyph glyph, out PangoRectangle inkRect, out PangoRectangle logicalRect) 241 { 242 pango_font_get_glyph_extents(pangoFont, glyph, &inkRect, &logicalRect); 243 } 244 245 /** 246 * Gets overall metric information for a font. Since the metrics may be 247 * substantially different for different scripts, a language tag can 248 * be provided to indicate that the metrics should be retrieved that 249 * correspond to the script(s) used by that language. 250 * 251 * If @font is %NULL, this function gracefully sets some sane values in the 252 * output variables and returns. 253 * 254 * Params: 255 * language = language tag used to determine which script to get the metrics 256 * for, or %NULL to indicate to get the metrics for the entire font. 257 * 258 * Return: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref() 259 * when finished using the object. 260 */ 261 public PgFontMetrics getMetrics(PgLanguage language) 262 { 263 auto p = pango_font_get_metrics(pangoFont, (language is null) ? null : language.getPgLanguageStruct()); 264 265 if(p is null) 266 { 267 return null; 268 } 269 270 return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true); 271 } 272 }