[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qfont.cpp:1807 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QFontMetrics Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QFontMetrics Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QFontMetrics class provides font metrics information.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qfontmetrics-h.html">qfontmetrics.h</a>></tt>
|
---|
| 37 | <p><a href="qfontmetrics-members.html">List of all member functions.</a>
|
---|
| 38 | <h2>Public Members</h2>
|
---|
| 39 | <ul>
|
---|
| 40 | <li class=fn><a href="#QFontMetrics"><b>QFontMetrics</b></a> ( const QFont & font )</li>
|
---|
| 41 | <li class=fn><a href="#QFontMetrics-2"><b>QFontMetrics</b></a> ( const QFont & font, QFont::Script script )</li>
|
---|
| 42 | <li class=fn><a href="#QFontMetrics-3"><b>QFontMetrics</b></a> ( const QFontMetrics & fm )</li>
|
---|
| 43 | <li class=fn><a href="#~QFontMetrics"><b>~QFontMetrics</b></a> ()</li>
|
---|
| 44 | <li class=fn>QFontMetrics & <a href="#operator-eq"><b>operator=</b></a> ( const QFontMetrics & fm )</li>
|
---|
| 45 | <li class=fn>int <a href="#ascent"><b>ascent</b></a> () const</li>
|
---|
| 46 | <li class=fn>int <a href="#descent"><b>descent</b></a> () const</li>
|
---|
| 47 | <li class=fn>int <a href="#height"><b>height</b></a> () const</li>
|
---|
| 48 | <li class=fn>int <a href="#leading"><b>leading</b></a> () const</li>
|
---|
| 49 | <li class=fn>int <a href="#lineSpacing"><b>lineSpacing</b></a> () const</li>
|
---|
| 50 | <li class=fn>int <a href="#minLeftBearing"><b>minLeftBearing</b></a> () const</li>
|
---|
| 51 | <li class=fn>int <a href="#minRightBearing"><b>minRightBearing</b></a> () const</li>
|
---|
| 52 | <li class=fn>int <a href="#maxWidth"><b>maxWidth</b></a> () const</li>
|
---|
| 53 | <li class=fn>bool <a href="#inFont"><b>inFont</b></a> ( QChar ch ) const</li>
|
---|
| 54 | <li class=fn>int <a href="#leftBearing"><b>leftBearing</b></a> ( QChar ch ) const</li>
|
---|
| 55 | <li class=fn>int <a href="#rightBearing"><b>rightBearing</b></a> ( QChar ch ) const</li>
|
---|
| 56 | <li class=fn>int <a href="#width-2"><b>width</b></a> ( const QString & str, int len = -1 ) const</li>
|
---|
| 57 | <li class=fn>int <a href="#width"><b>width</b></a> ( QChar ch ) const</li>
|
---|
| 58 | <li class=fn>int width ( char c ) const <em>(obsolete)</em></li>
|
---|
| 59 | <li class=fn>int <a href="#charWidth"><b>charWidth</b></a> ( const QString & str, int pos ) const</li>
|
---|
| 60 | <li class=fn>QRect <a href="#boundingRect-2"><b>boundingRect</b></a> ( const QString & str, int len = -1 ) const</li>
|
---|
| 61 | <li class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> ( QChar ch ) const</li>
|
---|
| 62 | <li class=fn>QRect <a href="#boundingRect-3"><b>boundingRect</b></a> ( int x, int y, int w, int h, int flgs, const QString & str, int len = -1, int tabstops = 0, int * tabarray = 0, QTextParag ** intern = 0 ) const</li>
|
---|
| 63 | <li class=fn>QSize <a href="#size"><b>size</b></a> ( int flgs, const QString & str, int len = -1, int tabstops = 0, int * tabarray = 0, QTextParag ** intern = 0 ) const</li>
|
---|
| 64 | <li class=fn>int <a href="#underlinePos"><b>underlinePos</b></a> () const</li>
|
---|
| 65 | <li class=fn>int <a href="#overlinePos"><b>overlinePos</b></a> () const</li>
|
---|
| 66 | <li class=fn>int <a href="#strikeOutPos"><b>strikeOutPos</b></a> () const</li>
|
---|
| 67 | <li class=fn>int <a href="#lineWidth"><b>lineWidth</b></a> () const</li>
|
---|
| 68 | </ul>
|
---|
| 69 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | The QFontMetrics class provides font metrics information.
|
---|
| 73 | <p>
|
---|
| 74 |
|
---|
| 75 | <p> QFontMetrics functions calculate the size of characters and
|
---|
| 76 | strings for a given font. There are three ways you can create a
|
---|
| 77 | QFontMetrics object:
|
---|
| 78 | <p> <ol type=1>
|
---|
| 79 | <li> Calling the QFontMetrics constructor with a <a href="qfont.html">QFont</a> creates a
|
---|
| 80 | font metrics object for a screen-compatible font, i.e. the font
|
---|
| 81 | cannot be a printer font<sup>*</sup>. If the font is changed
|
---|
| 82 | later, the font metrics object is <em>not</em> updated.
|
---|
| 83 | <p> <li> <a href="qwidget.html#fontMetrics">QWidget::fontMetrics</a>() returns the font metrics for a widget's
|
---|
| 84 | font. This is equivalent to QFontMetrics(widget->font()). If the
|
---|
| 85 | widget's font is changed later, the font metrics object is <em>not</em>
|
---|
| 86 | updated.
|
---|
| 87 | <p> <li> <a href="qpainter.html#fontMetrics">QPainter::fontMetrics</a>() returns the font metrics for a
|
---|
| 88 | painter's current font. If the painter's font is changed later, the
|
---|
| 89 | font metrics object is <em>not</em> updated.
|
---|
| 90 | </ol>
|
---|
| 91 | <p> <sup>*</sup> If you use a printer font the values returned may be
|
---|
| 92 | inaccurate. Printer fonts are not always accessible so the nearest
|
---|
| 93 | screen font is used if a printer font is supplied.
|
---|
| 94 | <p> Once created, the object provides functions to access the
|
---|
| 95 | individual metrics of the font, its characters, and for strings
|
---|
| 96 | rendered in the font.
|
---|
| 97 | <p> There are several functions that operate on the font: <a href="#ascent">ascent</a>(),
|
---|
| 98 | <a href="#descent">descent</a>(), <a href="#height">height</a>(), <a href="#leading">leading</a>() and <a href="#lineSpacing">lineSpacing</a>() return the basic
|
---|
| 99 | size properties of the font. The <a href="#underlinePos">underlinePos</a>(), <a href="#overlinePos">overlinePos</a>(),
|
---|
| 100 | <a href="#strikeOutPos">strikeOutPos</a>() and <a href="#lineWidth">lineWidth</a>() functions, return the properties of
|
---|
| 101 | the line that underlines, overlines or strikes out the
|
---|
| 102 | characters. These functions are all fast.
|
---|
| 103 | <p> There are also some functions that operate on the set of glyphs in
|
---|
| 104 | the font: <a href="#minLeftBearing">minLeftBearing</a>(), <a href="#minRightBearing">minRightBearing</a>() and <a href="#maxWidth">maxWidth</a>().
|
---|
| 105 | These are by necessity slow, and we recommend avoiding them if
|
---|
| 106 | possible.
|
---|
| 107 | <p> For each character, you can get its <a href="#width">width</a>(), <a href="#leftBearing">leftBearing</a>() and
|
---|
| 108 | <a href="#rightBearing">rightBearing</a>() and find out whether it is in the font using
|
---|
| 109 | <a href="#inFont">inFont</a>(). You can also treat the character as a string, and use
|
---|
| 110 | the string functions on it.
|
---|
| 111 | <p> The string functions include width(), to return the width of a
|
---|
| 112 | string in pixels (or points, for a printer), <a href="#boundingRect">boundingRect</a>(), to
|
---|
| 113 | return a rectangle large enough to contain the rendered string,
|
---|
| 114 | and <a href="#size">size</a>(), to return the size of that rectangle.
|
---|
| 115 | <p> Example:
|
---|
| 116 | <pre>
|
---|
| 117 | <a href="qfont.html">QFont</a> font( "times", 24 );
|
---|
| 118 | QFontMetrics fm( font );
|
---|
| 119 | int pixelsWide = fm.<a href="#width">width</a>( "What's the width of this text?" );
|
---|
| 120 | int pixelsHigh = fm.<a href="#height">height</a>();
|
---|
| 121 | </pre>
|
---|
| 122 |
|
---|
| 123 | <p> <p>See also <a href="qfont.html">QFont</a>, <a href="qfontinfo.html">QFontInfo</a>, <a href="qfontdatabase.html">QFontDatabase</a>, <a href="graphics.html">Graphics Classes</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
|
---|
| 124 |
|
---|
| 125 | <hr><h2>Member Function Documentation</h2>
|
---|
| 126 | <h3 class=fn><a name="QFontMetrics"></a>QFontMetrics::QFontMetrics ( const <a href="qfont.html">QFont</a> & font )
|
---|
| 127 | </h3>
|
---|
| 128 | Constructs a font metrics object for <em>font</em>.
|
---|
| 129 | <p> The font must be screen-compatible, i.e. a font you use when
|
---|
| 130 | drawing text in <a href="qwidget.html">widgets</a> or <a href="qpixmap.html">pixmaps</a>, not <a href="qpicture.html">QPicture</a> or <a href="qprinter.html">QPrinter</a>.
|
---|
| 131 | <p> The font metrics object holds the information for the font that is
|
---|
| 132 | passed in the constructor at the time it is created, and is not
|
---|
| 133 | updated if the font's attributes are changed later.
|
---|
| 134 | <p> Use <a href="qpainter.html#fontMetrics">QPainter::fontMetrics</a>() to get the font metrics when painting.
|
---|
| 135 | This will give correct results also when painting on paint device
|
---|
| 136 | that is not screen-compatible.
|
---|
| 137 |
|
---|
| 138 | <h3 class=fn><a name="QFontMetrics-2"></a>QFontMetrics::QFontMetrics ( const <a href="qfont.html">QFont</a> & font, <a href="qfont.html#Script-enum">QFont::Script</a> script )
|
---|
| 139 | </h3>
|
---|
| 140 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 141 | <p> Constructs a font metrics object for <em>font</em> using the given <em>script</em>.
|
---|
| 142 |
|
---|
| 143 | <h3 class=fn><a name="QFontMetrics-3"></a>QFontMetrics::QFontMetrics ( const <a href="qfontmetrics.html">QFontMetrics</a> & fm )
|
---|
| 144 | </h3>
|
---|
| 145 | Constructs a copy of <em>fm</em>.
|
---|
| 146 |
|
---|
| 147 | <h3 class=fn><a name="~QFontMetrics"></a>QFontMetrics::~QFontMetrics ()
|
---|
| 148 | </h3>
|
---|
| 149 | Destroys the font metrics object and frees all allocated
|
---|
| 150 | resources.
|
---|
| 151 |
|
---|
| 152 | <h3 class=fn>int <a name="ascent"></a>QFontMetrics::ascent () const
|
---|
| 153 | </h3>
|
---|
| 154 | Returns the ascent of the font.
|
---|
| 155 | <p> The ascent of a font is the distance from the baseline to the
|
---|
| 156 | highest position characters extend to. In practice, some font
|
---|
| 157 | designers break this rule, e.g. when they put more than one accent
|
---|
| 158 | on top of a character, or to accommodate an unusual character in
|
---|
| 159 | an exotic language, so it is possible (though rare) that this
|
---|
| 160 | value will be too small.
|
---|
| 161 | <p> <p>See also <a href="#descent">descent</a>().
|
---|
| 162 |
|
---|
| 163 | <p>Examples: <a href="drawdemo-example.html#x1064">drawdemo/drawdemo.cpp</a> and <a href="scrollview-example.html#x619">scrollview/scrollview.cpp</a>.
|
---|
| 164 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QFontMetrics::boundingRect ( <a href="qchar.html">QChar</a> ch ) const
|
---|
| 165 | </h3>
|
---|
| 166 | Returns the rectangle that is covered by ink if the character
|
---|
| 167 | specified by <em>ch</em> were to be drawn at the origin of the coordinate
|
---|
| 168 | system.
|
---|
| 169 | <p> Note that the bounding rectangle may extend to the left of (0, 0),
|
---|
| 170 | e.g. for italicized fonts, and that the text output may cover <em>all</em> pixels in the bounding rectangle. For a space character the rectangle
|
---|
| 171 | will usually be empty.
|
---|
| 172 | <p> Note that the rectangle usually extends both above and below the
|
---|
| 173 | base line.
|
---|
| 174 | <p> <b>Warning:</b> The width of the returned rectangle is not the advance width
|
---|
| 175 | of the character. Use <a href="#boundingRect">boundingRect</a>(const <a href="qstring.html">QString</a> &) or <a href="#width">width</a>() instead.
|
---|
| 176 | <p> <p>See also <a href="#width">width</a>().
|
---|
| 177 |
|
---|
| 178 | <p>Example: <a href="xform-example.html#x1225">xform/xform.cpp</a>.
|
---|
| 179 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect-2"></a>QFontMetrics::boundingRect ( const <a href="qstring.html">QString</a> & str, int len = -1 ) const
|
---|
| 180 | </h3>
|
---|
| 181 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 182 | <p> Returns the bounding rectangle that contains the first <em>len</em>
|
---|
| 183 | characters of string <em>str</em>.
|
---|
| 184 |
|
---|
| 185 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect-3"></a>QFontMetrics::boundingRect ( int x, int y, int w, int h, int flgs, const <a href="qstring.html">QString</a> & str, int len = -1, int tabstops = 0, int * tabarray = 0, QTextParag ** intern = 0 ) const
|
---|
| 186 | </h3>
|
---|
| 187 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 188 | <p> Returns the bounding rectangle of the first <em>len</em> characters of
|
---|
| 189 | <em>str</em>, which is the set of pixels the text would cover if drawn
|
---|
| 190 | at (0, 0). The drawing, and hence the bounding rectangle, is
|
---|
| 191 | constrained to the rectangle (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>).
|
---|
| 192 | <p> If <em>len</em> is negative (which is the default), the entire string is
|
---|
| 193 | used.
|
---|
| 194 | <p> The <em>flgs</em> argument is the bitwise OR of the following flags:
|
---|
| 195 | <ul>
|
---|
| 196 | <li> <tt>AlignAuto</tt> aligns to the left border for all languages except
|
---|
| 197 | Arabic and Hebrew where it aligns to the right.
|
---|
| 198 | <li> <tt>AlignLeft</tt> aligns to the left border.
|
---|
| 199 | <li> <tt>AlignRight</tt> aligns to the right border.
|
---|
| 200 | <li> <tt>AlignJustify</tt> produces justified text.
|
---|
| 201 | <li> <tt>AlignHCenter</tt> aligns horizontally centered.
|
---|
| 202 | <li> <tt>AlignTop</tt> aligns to the top border.
|
---|
| 203 | <li> <tt>AlignBottom</tt> aligns to the bottom border.
|
---|
| 204 | <li> <tt>AlignVCenter</tt> aligns vertically centered
|
---|
| 205 | <li> <tt>AlignCenter</tt> (== <tt>AlignHCenter | AlignVCenter</tt>)
|
---|
| 206 | <li> <tt>SingleLine</tt> ignores newline characters in the text.
|
---|
| 207 | <li> <tt>ExpandTabs</tt> expands tabs (see below)
|
---|
| 208 | <li> <tt>ShowPrefix</tt> interprets "&x" as "<u>x</u>", i.e. underlined.
|
---|
| 209 | <li> <tt>WordBreak</tt> breaks the text to fit the rectangle.
|
---|
| 210 | </ul>
|
---|
| 211 | <p> Horizontal alignment defaults to <tt>AlignAuto</tt> and vertical
|
---|
| 212 | alignment defaults to <tt>AlignTop</tt>.
|
---|
| 213 | <p> If several of the horizontal or several of the vertical alignment
|
---|
| 214 | flags are set, the resulting alignment is undefined.
|
---|
| 215 | <p> These flags are defined in <a href="qnamespace-h.html">qnamespace.h</a>.
|
---|
| 216 | <p> If <tt>ExpandTabs</tt> is set in <em>flgs</em>, then: if <em>tabarray</em> is
|
---|
| 217 | non-null, it specifies a 0-terminated sequence of pixel-positions
|
---|
| 218 | for tabs; otherwise if <em>tabstops</em> is non-zero, it is used as the
|
---|
| 219 | tab spacing (in pixels).
|
---|
| 220 | <p> Note that the bounding rectangle may extend to the left of (0, 0),
|
---|
| 221 | e.g. for italicized fonts, and that the text output may cover <em>all</em> pixels in the bounding rectangle.
|
---|
| 222 | <p> Newline characters are processed as linebreaks.
|
---|
| 223 | <p> Despite the different actual character heights, the heights of the
|
---|
| 224 | bounding rectangles of "Yes" and "yes" are the same.
|
---|
| 225 | <p> The bounding rectangle given by this function is somewhat larger
|
---|
| 226 | than that calculated by the simpler <a href="#boundingRect">boundingRect</a>() function. This
|
---|
| 227 | function uses the <a href="#minLeftBearing">maximum left</a> and
|
---|
| 228 | <a href="#minRightBearing">right</a> font bearings as is
|
---|
| 229 | necessary for multi-line text to align correctly. Also,
|
---|
| 230 | fontHeight() and <a href="#lineSpacing">lineSpacing</a>() are used to calculate the height,
|
---|
| 231 | rather than individual character heights.
|
---|
| 232 | <p> The <em>intern</em> argument should not be used.
|
---|
| 233 | <p> <p>See also <a href="#width">width</a>(), <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>(), and <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>.
|
---|
| 234 |
|
---|
| 235 | <h3 class=fn>int <a name="charWidth"></a>QFontMetrics::charWidth ( const <a href="qstring.html">QString</a> & str, int pos ) const
|
---|
| 236 | </h3>
|
---|
| 237 | Returns the width of the character at position <em>pos</em> in the
|
---|
| 238 | string <em>str</em>.
|
---|
| 239 | <p> The whole string is needed, as the glyph drawn may change
|
---|
| 240 | depending on the context (the letter before and after the current
|
---|
| 241 | one) for some languages (e.g. Arabic).
|
---|
| 242 | <p> This function also takes non spacing marks and ligatures into
|
---|
| 243 | account.
|
---|
| 244 |
|
---|
| 245 | <h3 class=fn>int <a name="descent"></a>QFontMetrics::descent () const
|
---|
| 246 | </h3>
|
---|
| 247 | Returns the descent of the font.
|
---|
| 248 | <p> The descent is the distance from the base line to the lowest point
|
---|
| 249 | characters extend to. (Note that this is different from X, which
|
---|
| 250 | adds 1 pixel.) In practice, some font designers break this rule,
|
---|
| 251 | e.g. to accommodate an unusual character in an exotic language, so
|
---|
| 252 | it is possible (though rare) that this value will be too small.
|
---|
| 253 | <p> <p>See also <a href="#ascent">ascent</a>().
|
---|
| 254 |
|
---|
| 255 | <p>Examples: <a href="drawdemo-example.html#x1065">drawdemo/drawdemo.cpp</a> and <a href="hello-example.html#x1629">hello/hello.cpp</a>.
|
---|
| 256 | <h3 class=fn>int <a name="height"></a>QFontMetrics::height () const
|
---|
| 257 | </h3>
|
---|
| 258 | Returns the height of the font.
|
---|
| 259 | <p> This is always equal to <a href="#ascent">ascent</a>()+descent()+1 (the 1 is for the
|
---|
| 260 | base line).
|
---|
| 261 | <p> <p>See also <a href="#leading">leading</a>() and <a href="#lineSpacing">lineSpacing</a>().
|
---|
| 262 |
|
---|
| 263 | <p>Examples: <a href="grapher-nsplugin-example.html#x2741">grapher/grapher.cpp</a>, <a href="hello-example.html#x1630">hello/hello.cpp</a>, and <a href="qfd-example.html#x1986">qfd/fontdisplayer.cpp</a>.
|
---|
| 264 | <h3 class=fn>bool <a name="inFont"></a>QFontMetrics::inFont ( <a href="qchar.html">QChar</a> ch ) const
|
---|
| 265 | </h3>
|
---|
| 266 | Returns TRUE if character <em>ch</em> is a valid character in the font;
|
---|
| 267 | otherwise returns FALSE.
|
---|
| 268 |
|
---|
| 269 | <p>Example: <a href="qfd-example.html#x1987">qfd/fontdisplayer.cpp</a>.
|
---|
| 270 | <h3 class=fn>int <a name="leading"></a>QFontMetrics::leading () const
|
---|
| 271 | </h3>
|
---|
| 272 | Returns the leading of the font.
|
---|
| 273 | <p> This is the natural inter-line spacing.
|
---|
| 274 | <p> <p>See also <a href="#height">height</a>() and <a href="#lineSpacing">lineSpacing</a>().
|
---|
| 275 |
|
---|
| 276 | <h3 class=fn>int <a name="leftBearing"></a>QFontMetrics::leftBearing ( <a href="qchar.html">QChar</a> ch ) const
|
---|
| 277 | </h3>
|
---|
| 278 | Returns the left bearing of character <em>ch</em> in the font.
|
---|
| 279 | <p> The left bearing is the right-ward distance of the left-most pixel
|
---|
| 280 | of the character from the logical origin of the character. This
|
---|
| 281 | value is negative if the pixels of the character extend to the
|
---|
| 282 | left of the logical origin.
|
---|
| 283 | <p> See <a href="#width">width</a>(<a href="qchar.html">QChar</a>) for a graphical description of this metric.
|
---|
| 284 | <p> <p>See also <a href="#rightBearing">rightBearing</a>(), <a href="#minLeftBearing">minLeftBearing</a>(), and <a href="#width">width</a>().
|
---|
| 285 |
|
---|
| 286 | <p>Example: <a href="qfd-example.html#x1988">qfd/fontdisplayer.cpp</a>.
|
---|
| 287 | <h3 class=fn>int <a name="lineSpacing"></a>QFontMetrics::lineSpacing () const
|
---|
| 288 | </h3>
|
---|
| 289 | Returns the distance from one base line to the next.
|
---|
| 290 | <p> This value is always equal to <a href="#leading">leading</a>()+height().
|
---|
| 291 | <p> <p>See also <a href="#height">height</a>() and <a href="#leading">leading</a>().
|
---|
| 292 |
|
---|
| 293 | <p>Examples: <a href="qfd-example.html#x1989">qfd/fontdisplayer.cpp</a>, <a href="qwerty-example.html#x369">qwerty/qwerty.cpp</a>, and <a href="scrollview-example.html#x620">scrollview/scrollview.cpp</a>.
|
---|
| 294 | <h3 class=fn>int <a name="lineWidth"></a>QFontMetrics::lineWidth () const
|
---|
| 295 | </h3>
|
---|
| 296 | Returns the width of the underline and strikeout lines, adjusted
|
---|
| 297 | for the point size of the font.
|
---|
| 298 | <p> <p>See also <a href="#underlinePos">underlinePos</a>(), <a href="#overlinePos">overlinePos</a>(), and <a href="#strikeOutPos">strikeOutPos</a>().
|
---|
| 299 |
|
---|
| 300 | <h3 class=fn>int <a name="maxWidth"></a>QFontMetrics::maxWidth () const
|
---|
| 301 | </h3>
|
---|
| 302 | Returns the width of the widest character in the font.
|
---|
| 303 |
|
---|
| 304 | <p>Example: <a href="qfd-example.html#x1990">qfd/fontdisplayer.cpp</a>.
|
---|
| 305 | <h3 class=fn>int <a name="minLeftBearing"></a>QFontMetrics::minLeftBearing () const
|
---|
| 306 | </h3>
|
---|
| 307 | Returns the minimum left bearing of the font.
|
---|
| 308 | <p> This is the smallest <a href="#leftBearing">leftBearing</a>(char) of all characters in the
|
---|
| 309 | font.
|
---|
| 310 | <p> Note that this function can be very slow if the font is large.
|
---|
| 311 | <p> <p>See also <a href="#minRightBearing">minRightBearing</a>() and <a href="#leftBearing">leftBearing</a>().
|
---|
| 312 |
|
---|
| 313 | <p>Example: <a href="qfd-example.html#x1991">qfd/fontdisplayer.cpp</a>.
|
---|
| 314 | <h3 class=fn>int <a name="minRightBearing"></a>QFontMetrics::minRightBearing () const
|
---|
| 315 | </h3>
|
---|
| 316 | Returns the minimum right bearing of the font.
|
---|
| 317 | <p> This is the smallest <a href="#rightBearing">rightBearing</a>(char) of all characters in the
|
---|
| 318 | font.
|
---|
| 319 | <p> Note that this function can be very slow if the font is large.
|
---|
| 320 | <p> <p>See also <a href="#minLeftBearing">minLeftBearing</a>() and <a href="#rightBearing">rightBearing</a>().
|
---|
| 321 |
|
---|
| 322 | <p>Example: <a href="qfd-example.html#x1992">qfd/fontdisplayer.cpp</a>.
|
---|
| 323 | <h3 class=fn><a href="qfontmetrics.html">QFontMetrics</a> & <a name="operator-eq"></a>QFontMetrics::operator= ( const <a href="qfontmetrics.html">QFontMetrics</a> & fm )
|
---|
| 324 | </h3>
|
---|
| 325 | Assigns the font metrics <em>fm</em>.
|
---|
| 326 |
|
---|
| 327 | <h3 class=fn>int <a name="overlinePos"></a>QFontMetrics::overlinePos () const
|
---|
| 328 | </h3>
|
---|
| 329 | Returns the distance from the base line to where an overline
|
---|
| 330 | should be drawn.
|
---|
| 331 | <p> <p>See also <a href="#underlinePos">underlinePos</a>(), <a href="#strikeOutPos">strikeOutPos</a>(), and <a href="#lineWidth">lineWidth</a>().
|
---|
| 332 |
|
---|
| 333 | <h3 class=fn>int <a name="rightBearing"></a>QFontMetrics::rightBearing ( <a href="qchar.html">QChar</a> ch ) const
|
---|
| 334 | </h3>
|
---|
| 335 | Returns the right bearing of character <em>ch</em> in the font.
|
---|
| 336 | <p> The right bearing is the left-ward distance of the right-most
|
---|
| 337 | pixel of the character from the logical origin of a subsequent
|
---|
| 338 | character. This value is negative if the pixels of the character
|
---|
| 339 | extend to the right of the <a href="#width">width</a>() of the character.
|
---|
| 340 | <p> See width() for a graphical description of this metric.
|
---|
| 341 | <p> <p>See also <a href="#leftBearing">leftBearing</a>(), <a href="#minRightBearing">minRightBearing</a>(), and <a href="#width">width</a>().
|
---|
| 342 |
|
---|
| 343 | <p>Example: <a href="qfd-example.html#x1993">qfd/fontdisplayer.cpp</a>.
|
---|
| 344 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="size"></a>QFontMetrics::size ( int flgs, const <a href="qstring.html">QString</a> & str, int len = -1, int tabstops = 0, int * tabarray = 0, QTextParag ** intern = 0 ) const
|
---|
| 345 | </h3>
|
---|
| 346 | Returns the size in pixels of the first <em>len</em> characters of <em>str</em>.
|
---|
| 347 | <p> If <em>len</em> is negative (the default), the entire string is used.
|
---|
| 348 | <p> The <em>flgs</em> argument is the bitwise OR of the following flags:
|
---|
| 349 | <ul>
|
---|
| 350 | <li> <tt>SingleLine</tt> ignores newline characters.
|
---|
| 351 | <li> <tt>ExpandTabs</tt> expands tabs (see below)
|
---|
| 352 | <li> <tt>ShowPrefix</tt> interprets "&x" as "<u>x</u>", i.e. underlined.
|
---|
| 353 | <li> <tt>WordBreak</tt> breaks the text to fit the rectangle.
|
---|
| 354 | </ul>
|
---|
| 355 | <p> These flags are defined in <a href="qnamespace-h.html">qnamespace.h</a>.
|
---|
| 356 | <p> If <tt>ExpandTabs</tt> is set in <em>flgs</em>, then: if <em>tabarray</em> is
|
---|
| 357 | non-null, it specifies a 0-terminated sequence of pixel-positions
|
---|
| 358 | for tabs; otherwise if <em>tabstops</em> is non-zero, it is used as the
|
---|
| 359 | tab spacing (in pixels).
|
---|
| 360 | <p> Newline characters are processed as linebreaks.
|
---|
| 361 | <p> Despite the different actual character heights, the heights of the
|
---|
| 362 | bounding rectangles of "Yes" and "yes" are the same.
|
---|
| 363 | <p> The <em>intern</em> argument should not be used.
|
---|
| 364 | <p> <p>See also <a href="#boundingRect">boundingRect</a>().
|
---|
| 365 |
|
---|
| 366 | <h3 class=fn>int <a name="strikeOutPos"></a>QFontMetrics::strikeOutPos () const
|
---|
| 367 | </h3>
|
---|
| 368 | Returns the distance from the base line to where the strikeout
|
---|
| 369 | line should be drawn.
|
---|
| 370 | <p> <p>See also <a href="#underlinePos">underlinePos</a>(), <a href="#overlinePos">overlinePos</a>(), and <a href="#lineWidth">lineWidth</a>().
|
---|
| 371 |
|
---|
| 372 | <h3 class=fn>int <a name="underlinePos"></a>QFontMetrics::underlinePos () const
|
---|
| 373 | </h3>
|
---|
| 374 | Returns the distance from the base line to where an underscore
|
---|
| 375 | should be drawn.
|
---|
| 376 | <p> <p>See also <a href="#overlinePos">overlinePos</a>(), <a href="#strikeOutPos">strikeOutPos</a>(), and <a href="#lineWidth">lineWidth</a>().
|
---|
| 377 |
|
---|
| 378 | <h3 class=fn>int <a name="width"></a>QFontMetrics::width ( <a href="qchar.html">QChar</a> ch ) const
|
---|
| 379 | </h3>
|
---|
| 380 | <p> <img src="bearings.png" align=right>
|
---|
| 381 | <p> Returns the logical width of character <em>ch</em> in pixels. This is a
|
---|
| 382 | distance appropriate for drawing a subsequent character after <em>ch</em>.
|
---|
| 383 | <p> Some of the metrics are described in the image to the right. The
|
---|
| 384 | central dark rectangles cover the logical <a href="#width">width</a>() of each
|
---|
| 385 | character. The outer pale rectangles cover the <a href="#leftBearing">leftBearing</a>() and
|
---|
| 386 | <a href="#rightBearing">rightBearing</a>() of each character. Notice that the bearings of "f"
|
---|
| 387 | in this particular font are both negative, while the bearings of
|
---|
| 388 | "o" are both positive.
|
---|
| 389 | <p> <b>Warning:</b> This function will produce incorrect results for Arabic
|
---|
| 390 | characters or non spacing marks in the middle of a string, as the
|
---|
| 391 | glyph shaping and positioning of marks that happens when
|
---|
| 392 | processing strings cannot be taken into account. Use <a href="#charWidth">charWidth</a>()
|
---|
| 393 | instead if you aren't looking for the width of isolated
|
---|
| 394 | characters.
|
---|
| 395 | <p> <p>See also <a href="#boundingRect">boundingRect</a>() and <a href="#charWidth">charWidth</a>().
|
---|
| 396 |
|
---|
| 397 | <p>Examples: <a href="drawdemo-example.html#x1066">drawdemo/drawdemo.cpp</a>, <a href="hello-example.html#x1631">hello/hello.cpp</a>, <a href="movies-example.html#x496">movies/main.cpp</a>, <a href="qfd-example.html#x1994">qfd/fontdisplayer.cpp</a>, and <a href="scrollview-example.html#x621">scrollview/scrollview.cpp</a>.
|
---|
| 398 | <h3 class=fn>int <a name="width-2"></a>QFontMetrics::width ( const <a href="qstring.html">QString</a> & str, int len = -1 ) const
|
---|
| 399 | </h3>
|
---|
| 400 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 401 | <p> Returns the width of the first <em>len</em> characters of string <em>str</em>.
|
---|
| 402 |
|
---|
| 403 | <h3 class=fn>int <a name="width-3"></a>QFontMetrics::width ( char c ) const
|
---|
| 404 | </h3>
|
---|
| 405 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 406 | <p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 407 | <p> Provided to aid porting from Qt 1.x.
|
---|
| 408 |
|
---|
| 409 | <!-- eof -->
|
---|
| 410 | <hr><p>
|
---|
| 411 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 412 | Copyright © 1995-2007
|
---|
| 413 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 414 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 415 | <td>Copyright © 2007
|
---|
| 416 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 417 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 418 | </table></div></address></body>
|
---|
| 419 | </html>
|
---|