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