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.PgFontMetrics; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gtkc.pango; 30 public import gtkc.pangotypes; 31 private import gtkd.Loader; 32 33 34 /** 35 * A #PangoFontMetrics structure holds the overall metric information 36 * for a font (possibly restricted to a script). The fields of this 37 * structure are private to implementations of a font backend. See 38 * the documentation of the corresponding getters for documentation 39 * of their meaning. 40 */ 41 public class PgFontMetrics 42 { 43 /** the main Gtk struct */ 44 protected PangoFontMetrics* pangoFontMetrics; 45 protected bool ownedRef; 46 47 /** Get the main Gtk struct */ 48 public PangoFontMetrics* getPgFontMetricsStruct(bool transferOwnership = false) 49 { 50 if (transferOwnership) 51 ownedRef = false; 52 return pangoFontMetrics; 53 } 54 55 /** the main Gtk struct as a void* */ 56 protected void* getStruct() 57 { 58 return cast(void*)pangoFontMetrics; 59 } 60 61 /** 62 * Sets our main struct and passes it to the parent class. 63 */ 64 public this (PangoFontMetrics* pangoFontMetrics, bool ownedRef = false) 65 { 66 this.pangoFontMetrics = pangoFontMetrics; 67 this.ownedRef = ownedRef; 68 } 69 70 ~this () 71 { 72 if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef ) 73 pango_font_metrics_unref(pangoFontMetrics); 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return pango_font_metrics_get_type(); 81 } 82 83 /** 84 * Creates a new #PangoFontMetrics structure. This is only for 85 * internal use by Pango backends and there is no public way 86 * to set the fields of the structure. 87 * 88 * Returns: a newly-created #PangoFontMetrics structure 89 * with a reference count of 1. 90 * 91 * Throws: ConstructionException GTK+ fails to create the object. 92 */ 93 public this() 94 { 95 auto p = pango_font_metrics_new(); 96 97 if(p is null) 98 { 99 throw new ConstructionException("null returned by new"); 100 } 101 102 this(cast(PangoFontMetrics*) p); 103 } 104 105 /** 106 * Gets the approximate character width for a font metrics structure. 107 * This is merely a representative value useful, for example, for 108 * determining the initial size for a window. Actual characters in 109 * text will be wider and narrower than this. 110 * 111 * Returns: the character width, in Pango units. 112 */ 113 public int getApproximateCharWidth() 114 { 115 return pango_font_metrics_get_approximate_char_width(pangoFontMetrics); 116 } 117 118 /** 119 * Gets the approximate digit width for a font metrics structure. 120 * This is merely a representative value useful, for example, for 121 * determining the initial size for a window. Actual digits in 122 * text can be wider or narrower than this, though this value 123 * is generally somewhat more accurate than the result of 124 * pango_font_metrics_get_approximate_char_width() for digits. 125 * 126 * Returns: the digit width, in Pango units. 127 */ 128 public int getApproximateDigitWidth() 129 { 130 return pango_font_metrics_get_approximate_digit_width(pangoFontMetrics); 131 } 132 133 /** 134 * Gets the ascent from a font metrics structure. The ascent is 135 * the distance from the baseline to the logical top of a line 136 * of text. (The logical top may be above or below the top of the 137 * actual drawn ink. It is necessary to lay out the text to figure 138 * where the ink will be.) 139 * 140 * Returns: the ascent, in Pango units. 141 */ 142 public int getAscent() 143 { 144 return pango_font_metrics_get_ascent(pangoFontMetrics); 145 } 146 147 /** 148 * Gets the descent from a font metrics structure. The descent is 149 * the distance from the baseline to the logical bottom of a line 150 * of text. (The logical bottom may be above or below the bottom of the 151 * actual drawn ink. It is necessary to lay out the text to figure 152 * where the ink will be.) 153 * 154 * Returns: the descent, in Pango units. 155 */ 156 public int getDescent() 157 { 158 return pango_font_metrics_get_descent(pangoFontMetrics); 159 } 160 161 /** 162 * Gets the suggested position to draw the strikethrough. 163 * The value returned is the distance <emphasis>above</emphasis> the 164 * baseline of the top of the strikethrough. 165 * 166 * Returns: the suggested strikethrough position, in Pango units. 167 * 168 * Since: 1.6 169 */ 170 public int getStrikethroughPosition() 171 { 172 return pango_font_metrics_get_strikethrough_position(pangoFontMetrics); 173 } 174 175 /** 176 * Gets the suggested thickness to draw for the strikethrough. 177 * 178 * Returns: the suggested strikethrough thickness, in Pango units. 179 * 180 * Since: 1.6 181 */ 182 public int getStrikethroughThickness() 183 { 184 return pango_font_metrics_get_strikethrough_thickness(pangoFontMetrics); 185 } 186 187 /** 188 * Gets the suggested position to draw the underline. 189 * The value returned is the distance <emphasis>above</emphasis> the 190 * baseline of the top of the underline. Since most fonts have 191 * underline positions beneath the baseline, this value is typically 192 * negative. 193 * 194 * Returns: the suggested underline position, in Pango units. 195 * 196 * Since: 1.6 197 */ 198 public int getUnderlinePosition() 199 { 200 return pango_font_metrics_get_underline_position(pangoFontMetrics); 201 } 202 203 /** 204 * Gets the suggested thickness to draw for the underline. 205 * 206 * Returns: the suggested underline thickness, in Pango units. 207 * 208 * Since: 1.6 209 */ 210 public int getUnderlineThickness() 211 { 212 return pango_font_metrics_get_underline_thickness(pangoFontMetrics); 213 } 214 215 /** 216 * Increase the reference count of a font metrics structure by one. 217 * 218 * Returns: @metrics 219 */ 220 public PgFontMetrics doref() 221 { 222 auto p = pango_font_metrics_ref(pangoFontMetrics); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true); 230 } 231 232 /** 233 * Decrease the reference count of a font metrics structure by one. If 234 * the result is zero, frees the structure and any associated 235 * memory. 236 */ 237 public void unref() 238 { 239 pango_font_metrics_unref(pangoFontMetrics); 240 } 241 }