1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qfontmetrics.cpp -->
<title>Qt 4.8: QFontMetricsF Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QFontMetricsF</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QFontMetricsF Class Reference</h1>
<!-- $$$QFontMetricsF-brief -->
<p>The QFontMetricsF class provides font metrics information. <a href="#details">More...</a></p>
<!-- @@@QFontMetricsF -->
<pre class="cpp"> <span class="preprocessor">#include <QFontMetricsF></span></pre><p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qfontmetricsf-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#QFontMetricsF">QFontMetricsF</a></b> ( const QFont & <i>font</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#QFontMetricsF-2">QFontMetricsF</a></b> ( const QFont & <i>font</i>, QPaintDevice * <i>paintdevice</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#QFontMetricsF-3">QFontMetricsF</a></b> ( const QFontMetrics & <i>fontMetrics</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#QFontMetricsF-4">QFontMetricsF</a></b> ( const QFontMetricsF & <i>fm</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#dtor.QFontMetricsF">~QFontMetricsF</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#ascent">ascent</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#averageCharWidth">averageCharWidth</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#boundingRect">boundingRect</a></b> ( const QString & <i>text</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#boundingRect-2">boundingRect</a></b> ( QChar <i>ch</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#boundingRect-3">boundingRect</a></b> ( const QRectF & <i>rect</i>, int <i>flags</i>, const QString & <i>text</i>, int <i>tabStops</i> = 0, int * <i>tabArray</i> = 0 ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#descent">descent</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#elidedText">elidedText</a></b> ( const QString & <i>text</i>, Qt::TextElideMode <i>mode</i>, qreal <i>width</i>, int <i>flags</i> = 0 ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#height">height</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#inFont">inFont</a></b> ( QChar <i>ch</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#inFontUcs4">inFontUcs4</a></b> ( uint <i>ch</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#leading">leading</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#leftBearing">leftBearing</a></b> ( QChar <i>ch</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#lineSpacing">lineSpacing</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#lineWidth">lineWidth</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#maxWidth">maxWidth</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#minLeftBearing">minLeftBearing</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#minRightBearing">minRightBearing</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#overlinePos">overlinePos</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#rightBearing">rightBearing</a></b> ( QChar <i>ch</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSizeF </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#size">size</a></b> ( int <i>flags</i>, const QString & <i>text</i>, int <i>tabStops</i> = 0, int * <i>tabArray</i> = 0 ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#strikeOutPos">strikeOutPos</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#tightBoundingRect">tightBoundingRect</a></b> ( const QString & <i>text</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#underlinePos">underlinePos</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#width">width</a></b> ( const QString & <i>text</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#width-2">width</a></b> ( QChar <i>ch</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#xHeight">xHeight</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#operator-not-eq">operator!=</a></b> ( const QFontMetricsF & <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#operator-not-eq-2">operator!=</a></b> ( const QFontMetricsF & <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFontMetricsF & </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#operator-eq">operator=</a></b> ( const QFontMetricsF & <i>fm</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFontMetricsF & </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#operator-eq-2">operator=</a></b> ( const QFontMetrics & <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#operator-eq-eq">operator==</a></b> ( const QFontMetricsF & <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfontmetricsf.html#operator-eq-eq-2">operator==</a></b> ( const QFontMetricsF & <i>other</i> ) const</td></tr>
</table>
<a name="details"></a>
<!-- $$$QFontMetricsF-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QFontMetricsF class provides font metrics information.</p>
<p>QFontMetricsF functions calculate the size of characters and strings for a given font. You can construct a QFontMetricsF object with an existing <a href="qfont.html">QFont</a> to obtain metrics for that font. If the font is changed later, the font metrics object is <i>not</i> updated.</p>
<p>Once created, the object provides functions to access the individual metrics of the font, its characters, and for strings rendered in the font.</p>
<p>There are several functions that operate on the font: <a href="qfontmetricsf.html#ascent">ascent</a>(), <a href="qfontmetricsf.html#descent">descent</a>(), <a href="qfontmetricsf.html#height">height</a>(), <a href="qfontmetricsf.html#leading">leading</a>() and <a href="qfontmetricsf.html#lineSpacing">lineSpacing</a>() return the basic size properties of the font. The <a href="qfontmetricsf.html#underlinePos">underlinePos</a>(), <a href="qfontmetricsf.html#overlinePos">overlinePos</a>(), <a href="qfontmetricsf.html#strikeOutPos">strikeOutPos</a>() and <a href="qfontmetricsf.html#lineWidth">lineWidth</a>() functions, return the properties of the line that underlines, overlines or strikes out the characters. These functions are all fast.</p>
<p>There are also some functions that operate on the set of glyphs in the font: <a href="qfontmetricsf.html#minLeftBearing">minLeftBearing</a>(), <a href="qfontmetricsf.html#minRightBearing">minRightBearing</a>() and <a href="qfontmetricsf.html#maxWidth">maxWidth</a>(). These are by necessity slow, and we recommend avoiding them if possible.</p>
<p>For each character, you can get its <a href="qfontmetricsf.html#width">width</a>(), <a href="qfontmetricsf.html#leftBearing">leftBearing</a>() and <a href="qfontmetricsf.html#rightBearing">rightBearing</a>() and find out whether it is in the font using <a href="qfontmetricsf.html#inFont">inFont</a>(). You can also treat the character as a string, and use the string functions on it.</p>
<p>The string functions include <a href="qfontmetricsf.html#width">width</a>(), to return the width of a string in pixels (or points, for a printer), <a href="qfontmetricsf.html#boundingRect">boundingRect</a>(), to return a rectangle large enough to contain the rendered string, and <a href="qfontmetricsf.html#size">size</a>(), to return the size of that rectangle.</p>
<p>Example:</p>
<pre class="cpp"> <span class="type"><a href="qfont.html">QFont</a></span> font(<span class="string">"times"</span><span class="operator">,</span> <span class="number">24</span>);
<span class="type">QFontMetricsF</span> fm(font);
<span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> pixelsWide <span class="operator">=</span> fm<span class="operator">.</span><a href="qfontmetricsf.html#width">width</a>(<span class="string">"What's the width of this text?"</span>);
<span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> pixelsHigh <span class="operator">=</span> fm<span class="operator">.</span><a href="qfontmetricsf.html#height">height</a>();</pre>
</div>
<p><b>See also </b><a href="qfont.html">QFont</a>, <a href="qfontinfo.html">QFontInfo</a>, and <a href="qfontdatabase.html">QFontDatabase</a>.</p>
<!-- @@@QFontMetricsF -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QFontMetricsF[overload1]$$$QFontMetricsFconstQFont& -->
<h3 class="fn"><a name="QFontMetricsF"></a>QFontMetricsF::<span class="name">QFontMetricsF</span> ( const <span class="type"><a href="qfont.html">QFont</a></span> & <i>font</i> )</h3>
<p>Constructs a font metrics object for <i>font</i>.</p>
<p>The font metrics will be compatible with the paintdevice used to create <i>font</i>.</p>
<p>The font metrics object holds the information for the font that is passed in the constructor at the time it is created, and is not updated if the font's attributes are changed later.</p>
<p>Use <a href="qfontmetricsf.html">QFontMetricsF</a>(const <a href="qfont.html">QFont</a> &, <a href="qpaintdevice.html">QPaintDevice</a> *) to get the font metrics that are compatible with a certain paint device.</p>
<!-- @@@QFontMetricsF -->
<!-- $$$QFontMetricsF$$$QFontMetricsFconstQFont&QPaintDevice* -->
<h3 class="fn"><a name="QFontMetricsF-2"></a>QFontMetricsF::<span class="name">QFontMetricsF</span> ( const <span class="type"><a href="qfont.html">QFont</a></span> & <i>font</i>, <span class="type"><a href="qpaintdevice.html">QPaintDevice</a></span> * <i>paintdevice</i> )</h3>
<p>Constructs a font metrics object for <i>font</i> and <i>paintdevice</i>.</p>
<p>The font metrics will be compatible with the paintdevice passed. If the <i>paintdevice</i> is 0, the metrics will be screen-compatible, ie. the metrics you get if you use the font for drawing text on a <a href="qwidget.html">widgets</a> or <a href="qpixmap.html">pixmaps</a>, not on a <a href="qpicture.html">QPicture</a> or <a href="qprinter.html">QPrinter</a>.</p>
<p>The font metrics object holds the information for the font that is passed in the constructor at the time it is created, and is not updated if the font's attributes are changed later.</p>
<!-- @@@QFontMetricsF -->
<!-- $$$QFontMetricsF$$$QFontMetricsFconstQFontMetrics& -->
<h3 class="fn"><a name="QFontMetricsF-3"></a>QFontMetricsF::<span class="name">QFontMetricsF</span> ( const <span class="type"><a href="qfontmetrics.html">QFontMetrics</a></span> & <i>fontMetrics</i> )</h3>
<p>Constructs a font metrics object with floating point precision from the given <i>fontMetrics</i> object.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@QFontMetricsF -->
<!-- $$$QFontMetricsF$$$QFontMetricsFconstQFontMetricsF& -->
<h3 class="fn"><a name="QFontMetricsF-4"></a>QFontMetricsF::<span class="name">QFontMetricsF</span> ( const <span class="type">QFontMetricsF</span> & <i>fm</i> )</h3>
<p>Constructs a copy of <i>fm</i>.</p>
<!-- @@@QFontMetricsF -->
<!-- $$$~QFontMetricsF[overload1]$$$~QFontMetricsF -->
<h3 class="fn"><a name="dtor.QFontMetricsF"></a>QFontMetricsF::<span class="name">~QFontMetricsF</span> ()</h3>
<p>Destroys the font metrics object and frees all allocated resources.</p>
<!-- @@@~QFontMetricsF -->
<!-- $$$ascent[overload1]$$$ascent -->
<h3 class="fn"><a name="ascent"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">ascent</span> () const</h3>
<p>Returns the ascent of the font.</p>
<p>The ascent of a font is the distance from the baseline to the highest position characters extend to. In practice, some font designers break this rule, e.g. when they put more than one accent on top of a character, or to accommodate an unusual character in an exotic language, so it is possible (though rare) that this value will be too small.</p>
<p><b>See also </b><a href="qfontmetricsf.html#descent">descent</a>().</p>
<!-- @@@ascent -->
<!-- $$$averageCharWidth[overload1]$$$averageCharWidth -->
<h3 class="fn"><a name="averageCharWidth"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">averageCharWidth</span> () const</h3>
<p>Returns the average width of glyphs in the font.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@averageCharWidth -->
<!-- $$$boundingRect[overload1]$$$boundingRectconstQString& -->
<h3 class="fn"><a name="boundingRect"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QFontMetricsF::<span class="name">boundingRect</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> ) const</h3>
<p>Returns the bounding rectangle of the characters in the string specified by <i>text</i>. The bounding rectangle always covers at least the set of pixels the text would cover if drawn at (0, 0).</p>
<p>Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the <a href="qfontmetricsf.html#width">width</a>() method returns.</p>
<p>If you want to know the advance width of the string (to layout a set of strings next to each other), use <a href="qfontmetricsf.html#width">width</a>() instead.</p>
<p>Newline characters are processed as normal characters, <i>not</i> as linebreaks.</p>
<p>The height of the bounding rectangle is at least as large as the value returned <a href="qfontmetricsf.html#height">height</a>().</p>
<p><b>See also </b><a href="qfontmetricsf.html#width">width</a>(), <a href="qfontmetricsf.html#height">height</a>(), and <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>().</p>
<!-- @@@boundingRect -->
<!-- $$$boundingRect$$$boundingRectQChar -->
<h3 class="fn"><a name="boundingRect-2"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QFontMetricsF::<span class="name">boundingRect</span> ( <span class="type"><a href="qchar.html">QChar</a></span> <i>ch</i> ) const</h3>
<p>Returns the bounding rectangle of the character <i>ch</i> relative to the left-most point on the base line.</p>
<p>Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the text output may cover <i>all</i> pixels in the bounding rectangle.</p>
<p>Note that the rectangle usually extends both above and below the base line.</p>
<p><b>See also </b><a href="qfontmetricsf.html#width">width</a>().</p>
<!-- @@@boundingRect -->
<!-- $$$boundingRect$$$boundingRectconstQRectF&intconstQString&intint* -->
<h3 class="fn"><a name="boundingRect-3"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QFontMetricsF::<span class="name">boundingRect</span> ( const <span class="type"><a href="qrectf.html">QRectF</a></span> & <i>rect</i>, <span class="type">int</span> <i>flags</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type">int</span> <i>tabStops</i> = 0, <span class="type">int</span> * <i>tabArray</i> = 0 ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the bounding rectangle of the characters in the given <i>text</i>. This is the set of pixels the text would cover if drawn when constrained to the bounding rectangle specified by <i>rect</i>.</p>
<p>The <i>flags</i> argument is the bitwise OR of the following flags:</p>
<ul>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignLeft</a> aligns to the left border, except for Arabic and Hebrew where it aligns to the right.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignRight</a> aligns to the right border, except for Arabic and Hebrew where it aligns to the left.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignJustify</a> produces justified text.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignHCenter</a> aligns horizontally centered.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignTop</a> aligns to the top border.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignBottom</a> aligns to the bottom border.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignVCenter</a> aligns vertically centered</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignCenter</a> (== <tt>Qt::AlignHCenter | Qt::AlignVCenter</tt>)</li>
<li><a href="qt.html#TextFlag-enum">Qt::TextSingleLine</a> ignores newline characters in the text.</li>
<li><a href="qt.html#TextFlag-enum">Qt::TextExpandTabs</a> expands tabs (see below)</li>
<li><a href="qt.html#TextFlag-enum">Qt::TextShowMnemonic</a> interprets "&x" as <u>x</u>; i.e., underlined.</li>
<li><a href="qt.html#TextFlag-enum">Qt::TextWordWrap</a> breaks the text to fit the rectangle.</li>
</ul>
<p><a href="qt.html#Orientation-enum">Qt::Horizontal</a> alignment defaults to <a href="qt.html#AlignmentFlag-enum">Qt::AlignLeft</a> and vertical alignment defaults to <a href="qt.html#AlignmentFlag-enum">Qt::AlignTop</a>.</p>
<p>If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.</p>
<p>These flags are defined in <a href="qt.html#AlignmentFlag-enum">Qt::AlignmentFlag</a>.</p>
<p>If <a href="qt.html#TextFlag-enum">Qt::TextExpandTabs</a> is set in <i>flags</i>, the following behavior is used to interpret tab characters in the text:</p>
<ul>
<li>If <i>tabArray</i> is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs in the text.</li>
<li>If <i>tabStops</i> is non-zero, it is used as the tab spacing (in pixels).</li>
</ul>
<p>Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts.</p>
<p>Newline characters are processed as line breaks.</p>
<p>Despite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same.</p>
<p>The bounding rectangle returned by this function is somewhat larger than that calculated by the simpler <a href="qfontmetricsf.html#boundingRect">boundingRect</a>() function. This function uses the <a href="qfontmetricsf.html#minLeftBearing">maximum left</a> and <a href="qfontmetricsf.html#minRightBearing">right</a> font bearings as is necessary for multi-line text to align correctly. Also, fontHeight() and <a href="qfontmetricsf.html#lineSpacing">lineSpacing</a>() are used to calculate the height, rather than individual character heights.</p>
<p><b>See also </b><a href="qfontmetricsf.html#width">width</a>(), <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>(), and <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a>.</p>
<!-- @@@boundingRect -->
<!-- $$$descent[overload1]$$$descent -->
<h3 class="fn"><a name="descent"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">descent</span> () const</h3>
<p>Returns the descent of the font.</p>
<p>The descent is the distance from the base line to the lowest point characters extend to. (Note that this is different from X, which adds 1 pixel.) In practice, some font designers break this rule, e.g. to accommodate an unusual character in an exotic language, so it is possible (though rare) that this value will be too small.</p>
<p><b>See also </b><a href="qfontmetricsf.html#ascent">ascent</a>().</p>
<!-- @@@descent -->
<!-- $$$elidedText[overload1]$$$elidedTextconstQString&Qt::TextElideModeqrealint -->
<h3 class="fn"><a name="elidedText"></a><span class="type"><a href="qstring.html">QString</a></span> QFontMetricsF::<span class="name">elidedText</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qt.html#TextElideMode-enum">Qt::TextElideMode</a></span> <i>mode</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>width</i>, <span class="type">int</span> <i>flags</i> = 0 ) const</h3>
<p>If the string <i>text</i> is wider than <i>width</i>, returns an elided version of the string (i.e., a string with "..." in it). Otherwise, returns the original string.</p>
<p>The <i>mode</i> parameter specifies whether the text is elided on the left (e.g., "...tech"), in the middle (e.g., "Tr...ch"), or on the right (e.g., "Trol...").</p>
<p>The <i>width</i> is specified in pixels, not characters.</p>
<p>The <i>flags</i> argument is optional and currently only supports <a href="qt.html#TextFlag-enum">Qt::TextShowMnemonic</a> as value.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@elidedText -->
<!-- $$$height[overload1]$$$height -->
<h3 class="fn"><a name="height"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">height</span> () const</h3>
<p>Returns the height of the font.</p>
<p>This is always equal to <a href="qfontmetricsf.html#ascent">ascent</a>()+<a href="qfontmetricsf.html#descent">descent</a>()+1 (the 1 is for the base line).</p>
<p><b>See also </b><a href="qfontmetricsf.html#leading">leading</a>() and <a href="qfontmetricsf.html#lineSpacing">lineSpacing</a>().</p>
<!-- @@@height -->
<!-- $$$inFont[overload1]$$$inFontQChar -->
<h3 class="fn"><a name="inFont"></a><span class="type">bool</span> QFontMetricsF::<span class="name">inFont</span> ( <span class="type"><a href="qchar.html">QChar</a></span> <i>ch</i> ) const</h3>
<p>Returns true if character <i>ch</i> is a valid character in the font; otherwise returns false.</p>
<!-- @@@inFont -->
<!-- $$$inFontUcs4[overload1]$$$inFontUcs4uint -->
<h3 class="fn"><a name="inFontUcs4"></a><span class="type">bool</span> QFontMetricsF::<span class="name">inFontUcs4</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>ch</i> ) const</h3>
<p>Returns true if the character given by <i>ch</i>, encoded in UCS-4/UTF-32, is a valid character in the font; otherwise returns false.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@inFontUcs4 -->
<!-- $$$leading[overload1]$$$leading -->
<h3 class="fn"><a name="leading"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">leading</span> () const</h3>
<p>Returns the leading of the font.</p>
<p>This is the natural inter-line spacing.</p>
<p><b>See also </b><a href="qfontmetricsf.html#height">height</a>() and <a href="qfontmetricsf.html#lineSpacing">lineSpacing</a>().</p>
<!-- @@@leading -->
<!-- $$$leftBearing[overload1]$$$leftBearingQChar -->
<h3 class="fn"><a name="leftBearing"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">leftBearing</span> ( <span class="type"><a href="qchar.html">QChar</a></span> <i>ch</i> ) const</h3>
<p>Returns the left bearing of character <i>ch</i> in the font.</p>
<p>The left bearing is the right-ward distance of the left-most pixel of the character from the logical origin of the character. This value is negative if the pixels of the character extend to the left of the logical origin.</p>
<p>See width(<a href="qchar.html">QChar</a>) for a graphical description of this metric.</p>
<p><b>See also </b><a href="qfontmetricsf.html#rightBearing">rightBearing</a>(), <a href="qfontmetricsf.html#minLeftBearing">minLeftBearing</a>(), and <a href="qfontmetricsf.html#width">width</a>().</p>
<!-- @@@leftBearing -->
<!-- $$$lineSpacing[overload1]$$$lineSpacing -->
<h3 class="fn"><a name="lineSpacing"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">lineSpacing</span> () const</h3>
<p>Returns the distance from one base line to the next.</p>
<p>This value is always equal to <a href="qfontmetricsf.html#leading">leading</a>()+<a href="qfontmetricsf.html#height">height</a>().</p>
<p><b>See also </b><a href="qfontmetricsf.html#height">height</a>() and <a href="qfontmetricsf.html#leading">leading</a>().</p>
<!-- @@@lineSpacing -->
<!-- $$$lineWidth[overload1]$$$lineWidth -->
<h3 class="fn"><a name="lineWidth"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">lineWidth</span> () const</h3>
<p>Returns the width of the underline and strikeout lines, adjusted for the point size of the font.</p>
<p><b>See also </b><a href="qfontmetricsf.html#underlinePos">underlinePos</a>(), <a href="qfontmetricsf.html#overlinePos">overlinePos</a>(), and <a href="qfontmetricsf.html#strikeOutPos">strikeOutPos</a>().</p>
<!-- @@@lineWidth -->
<!-- $$$maxWidth[overload1]$$$maxWidth -->
<h3 class="fn"><a name="maxWidth"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">maxWidth</span> () const</h3>
<p>Returns the width of the widest character in the font.</p>
<!-- @@@maxWidth -->
<!-- $$$minLeftBearing[overload1]$$$minLeftBearing -->
<h3 class="fn"><a name="minLeftBearing"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">minLeftBearing</span> () const</h3>
<p>Returns the minimum left bearing of the font.</p>
<p>This is the smallest leftBearing(char) of all characters in the font.</p>
<p>Note that this function can be very slow if the font is large.</p>
<p><b>See also </b><a href="qfontmetricsf.html#minRightBearing">minRightBearing</a>() and <a href="qfontmetricsf.html#leftBearing">leftBearing</a>().</p>
<!-- @@@minLeftBearing -->
<!-- $$$minRightBearing[overload1]$$$minRightBearing -->
<h3 class="fn"><a name="minRightBearing"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">minRightBearing</span> () const</h3>
<p>Returns the minimum right bearing of the font.</p>
<p>This is the smallest rightBearing(char) of all characters in the font.</p>
<p>Note that this function can be very slow if the font is large.</p>
<p><b>See also </b><a href="qfontmetricsf.html#minLeftBearing">minLeftBearing</a>() and <a href="qfontmetricsf.html#rightBearing">rightBearing</a>().</p>
<!-- @@@minRightBearing -->
<!-- $$$overlinePos[overload1]$$$overlinePos -->
<h3 class="fn"><a name="overlinePos"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">overlinePos</span> () const</h3>
<p>Returns the distance from the base line to where an overline should be drawn.</p>
<p><b>See also </b><a href="qfontmetricsf.html#underlinePos">underlinePos</a>(), <a href="qfontmetricsf.html#strikeOutPos">strikeOutPos</a>(), and <a href="qfontmetricsf.html#lineWidth">lineWidth</a>().</p>
<!-- @@@overlinePos -->
<!-- $$$rightBearing[overload1]$$$rightBearingQChar -->
<h3 class="fn"><a name="rightBearing"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">rightBearing</span> ( <span class="type"><a href="qchar.html">QChar</a></span> <i>ch</i> ) const</h3>
<p>Returns the right bearing of character <i>ch</i> in the font.</p>
<p>The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if the pixels of the character extend to the right of the <a href="qfontmetricsf.html#width">width</a>() of the character.</p>
<p>See <a href="qfontmetricsf.html#width">width</a>() for a graphical description of this metric.</p>
<p><b>See also </b><a href="qfontmetricsf.html#leftBearing">leftBearing</a>(), <a href="qfontmetricsf.html#minRightBearing">minRightBearing</a>(), and <a href="qfontmetricsf.html#width">width</a>().</p>
<!-- @@@rightBearing -->
<!-- $$$size[overload1]$$$sizeintconstQString&intint* -->
<h3 class="fn"><a name="size"></a><span class="type"><a href="qsizef.html">QSizeF</a></span> QFontMetricsF::<span class="name">size</span> ( <span class="type">int</span> <i>flags</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type">int</span> <i>tabStops</i> = 0, <span class="type">int</span> * <i>tabArray</i> = 0 ) const</h3>
<p>Returns the size in pixels of the characters in the given <i>text</i>.</p>
<p>The <i>flags</i> argument is the bitwise OR of the following flags:</p>
<ul>
<li><a href="qt.html#TextFlag-enum">Qt::TextSingleLine</a> ignores newline characters.</li>
<li><a href="qt.html#TextFlag-enum">Qt::TextExpandTabs</a> expands tabs (see below)</li>
<li><a href="qt.html#TextFlag-enum">Qt::TextShowMnemonic</a> interprets "&x" as <u>x</u>; i.e., underlined.</li>
<li>Qt::TextWordBreak breaks the text to fit the rectangle.</li>
</ul>
<p>These flags are defined in <a href="qt-qt3.html#TextFlags-typedef" class="compat">Qt::TextFlags</a>.</p>
<p>If <a href="qt.html#TextFlag-enum">Qt::TextExpandTabs</a> is set in <i>flags</i>, the following behavior is used to interpret tab characters in the text:</p>
<ul>
<li>If <i>tabArray</i> is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs in the text.</li>
<li>If <i>tabStops</i> is non-zero, it is used as the tab spacing (in pixels).</li>
</ul>
<p>Newline characters are processed as line breaks.</p>
<p>Note: Despite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same.</p>
<p><b>See also </b><a href="qfontmetricsf.html#boundingRect">boundingRect</a>().</p>
<!-- @@@size -->
<!-- $$$strikeOutPos[overload1]$$$strikeOutPos -->
<h3 class="fn"><a name="strikeOutPos"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">strikeOutPos</span> () const</h3>
<p>Returns the distance from the base line to where the strikeout line should be drawn.</p>
<p><b>See also </b><a href="qfontmetricsf.html#underlinePos">underlinePos</a>(), <a href="qfontmetricsf.html#overlinePos">overlinePos</a>(), and <a href="qfontmetricsf.html#lineWidth">lineWidth</a>().</p>
<!-- @@@strikeOutPos -->
<!-- $$$tightBoundingRect[overload1]$$$tightBoundingRectconstQString& -->
<h3 class="fn"><a name="tightBoundingRect"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QFontMetricsF::<span class="name">tightBoundingRect</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> ) const</h3>
<p>Returns a tight bounding rectangle around the characters in the string specified by <i>text</i>. The bounding rectangle always covers at least the set of pixels the text would cover if drawn at (0, 0).</p>
<p>Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the <a href="qfontmetricsf.html#width">width</a>() method returns.</p>
<p>If you want to know the advance width of the string (to layout a set of strings next to each other), use <a href="qfontmetricsf.html#width">width</a>() instead.</p>
<p>Newline characters are processed as normal characters, <i>not</i> as linebreaks.</p>
<p><b>Warning:</b> Calling this method is very slow on Windows.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qfontmetricsf.html#width">width</a>(), <a href="qfontmetricsf.html#height">height</a>(), and <a href="qfontmetricsf.html#boundingRect">boundingRect</a>().</p>
<!-- @@@tightBoundingRect -->
<!-- $$$underlinePos[overload1]$$$underlinePos -->
<h3 class="fn"><a name="underlinePos"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">underlinePos</span> () const</h3>
<p>Returns the distance from the base line to where an underscore should be drawn.</p>
<p><b>See also </b><a href="qfontmetricsf.html#overlinePos">overlinePos</a>(), <a href="qfontmetricsf.html#strikeOutPos">strikeOutPos</a>(), and <a href="qfontmetricsf.html#lineWidth">lineWidth</a>().</p>
<!-- @@@underlinePos -->
<!-- $$$width[overload1]$$$widthconstQString& -->
<h3 class="fn"><a name="width"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">width</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> ) const</h3>
<p>Returns the width in pixels of the characters in the given <i>text</i>.</p>
<p>Note that this value is <i>not</i> equal to the width returned by <a href="qfontmetricsf.html#boundingRect">boundingRect</a>().width() because <a href="qfontmetricsf.html#boundingRect">boundingRect</a>() returns a rectangle describing the pixels this string will cover whereas width() returns the distance to where the next string should be drawn.</p>
<p><b>See also </b><a href="qfontmetricsf.html#boundingRect">boundingRect</a>().</p>
<!-- @@@width -->
<!-- $$$width$$$widthQChar -->
<h3 class="fn"><a name="width-2"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">width</span> ( <span class="type"><a href="qchar.html">QChar</a></span> <i>ch</i> ) const</h3>
<p>This is an overloaded function.</p>
<p class="centerAlign"><img src="images/bearings.png" alt="Bearings" /></p><p>Returns the logical width of character <i>ch</i> in pixels. This is a distance appropriate for drawing a subsequent character after <i>ch</i>.</p>
<p>Some of the metrics are described in the image to the right. The central dark rectangles cover the logical <a href="qfontmetricsf.html#width">width</a>() of each character. The outer pale rectangles cover the <a href="qfontmetricsf.html#leftBearing">leftBearing</a>() and <a href="qfontmetricsf.html#rightBearing">rightBearing</a>() of each character. Notice that the bearings of "f" in this particular font are both negative, while the bearings of "o" are both positive.</p>
<p><b>Warning:</b> This function will produce incorrect results for Arabic characters or non-spacing marks in the middle of a string, as the glyph shaping and positioning of marks that happens when processing strings cannot be taken into account. When implementing an interactive text control, use <a href="qtextlayout.html">QTextLayout</a> instead.</p>
<p><b>See also </b><a href="qfontmetricsf.html#boundingRect">boundingRect</a>().</p>
<!-- @@@width -->
<!-- $$$xHeight[overload1]$$$xHeight -->
<h3 class="fn"><a name="xHeight"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QFontMetricsF::<span class="name">xHeight</span> () const</h3>
<p>Returns the 'x' height of the font. This is often but not always the same as the height of the character 'x'.</p>
<!-- @@@xHeight -->
<!-- $$$operator!=[overload1]$$$operator!=constQFontMetricsF& -->
<h3 class="fn"><a name="operator-not-eq"></a><span class="type">bool</span> QFontMetricsF::<span class="name">operator!=</span> ( const <span class="type">QFontMetricsF</span> & <i>other</i> )</h3>
<p>Returns true if the font metrics are not equal to the <i>other</i> font metrics; otherwise returns false.</p>
<p><b>See also </b><a href="qfontmetricsf.html#operator-eq-eq">operator==</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator!=$$$operator!=constQFontMetricsF& -->
<h3 class="fn"><a name="operator-not-eq-2"></a><span class="type">bool</span> QFontMetricsF::<span class="name">operator!=</span> ( const <span class="type">QFontMetricsF</span> & <i>other</i> ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns true if the font metrics are not equal to the <i>other</i> font metrics; otherwise returns false.</p>
<p><b>See also </b><a href="qfontmetricsf.html#operator-eq-eq">operator==</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator=[overload1]$$$operator=constQFontMetricsF& -->
<h3 class="fn"><a name="operator-eq"></a><span class="type">QFontMetricsF</span> & QFontMetricsF::<span class="name">operator=</span> ( const <span class="type">QFontMetricsF</span> & <i>fm</i> )</h3>
<p>Assigns the font metrics <i>fm</i> to this font metrics object.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=constQFontMetrics& -->
<h3 class="fn"><a name="operator-eq-2"></a><span class="type">QFontMetricsF</span> & QFontMetricsF::<span class="name">operator=</span> ( const <span class="type"><a href="qfontmetrics.html">QFontMetrics</a></span> & <i>other</i> )</h3>
<p>Assigns <i>other</i> to this object.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQFontMetricsF& -->
<h3 class="fn"><a name="operator-eq-eq"></a><span class="type">bool</span> QFontMetricsF::<span class="name">operator==</span> ( const <span class="type">QFontMetricsF</span> & <i>other</i> )</h3>
<p>Returns true if the font metrics are equal to the <i>other</i> font metrics; otherwise returns false.</p>
<p>Two font metrics are considered equal if they were constructed from the same <a href="qfont.html">QFont</a> and the paint devices they were constructed for are considered to be compatible.</p>
<!-- @@@operator== -->
<!-- $$$operator==$$$operator==constQFontMetricsF& -->
<h3 class="fn"><a name="operator-eq-eq-2"></a><span class="type">bool</span> QFontMetricsF::<span class="name">operator==</span> ( const <span class="type">QFontMetricsF</span> & <i>other</i> ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns true if the font metrics are equal to the <i>other</i> font metrics; otherwise returns false.</p>
<p>Two font metrics are considered equal if they were constructed from the same <a href="qfont.html">QFont</a> and the paint devices they were constructed for are considered to be compatible.</p>
<!-- @@@operator== -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|