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