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