~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qfontmetrics.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/text/qfontmetrics.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QFontMetrics Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QFontMetrics Class Reference</h1>
 
21
<p>The QFontMetrics class provides font metrics information. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QFontMetrics&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<ul>
 
24
<li><a href="qfontmetrics-members.html">List of all members, including inherited members</a></li>
 
25
<li><a href="qfontmetrics-qt3.html">Qt 3 support members</a></li>
 
26
</ul>
 
27
<a name="public-functions"></a>
 
28
<h3>Public Functions</h3>
 
29
<ul>
 
30
<li><div class="fn"/><b><a href="qfontmetrics.html#QFontMetrics">QFontMetrics</a></b> ( const QFont &amp; <i>font</i> )</li>
 
31
<li><div class="fn"/><b><a href="qfontmetrics.html#QFontMetrics-2">QFontMetrics</a></b> ( const QFont &amp; <i>font</i>, QPaintDevice * <i>paintdevice</i> )</li>
 
32
<li><div class="fn"/><b><a href="qfontmetrics.html#QFontMetrics-3">QFontMetrics</a></b> ( const QFontMetrics &amp; <i>fm</i> )</li>
 
33
<li><div class="fn"/><b><a href="qfontmetrics.html#dtor.QFontMetrics">~QFontMetrics</a></b> ()</li>
 
34
<li><div class="fn"/>int <b><a href="qfontmetrics.html#ascent">ascent</a></b> () const</li>
 
35
<li><div class="fn"/>QRect <b><a href="qfontmetrics.html#boundingRect">boundingRect</a></b> ( QChar <i>ch</i> ) const</li>
 
36
<li><div class="fn"/>QRect <b><a href="qfontmetrics.html#boundingRect-2">boundingRect</a></b> ( const QString &amp; <i>str</i> ) const</li>
 
37
<li><div class="fn"/>QRect <b><a href="qfontmetrics.html#boundingRect-5">boundingRect</a></b> ( int <i>x</i>, int <i>y</i>, int <i>width</i>, int <i>height</i>, int <i>flags</i>, const QString &amp; <i>text</i>, int <i>tabstops</i> = 0, int * <i>tabarray</i> = 0 ) const</li>
 
38
<li><div class="fn"/>QRect <b><a href="qfontmetrics.html#boundingRect-6">boundingRect</a></b> ( const QRect &amp; <i>r</i>, int <i>flgs</i>, const QString &amp; <i>str</i>, int <i>tabstops</i> = 0, int * <i>tabarray</i> = 0 ) const</li>
 
39
<li><div class="fn"/>int <b><a href="qfontmetrics.html#charWidth">charWidth</a></b> ( const QString &amp; <i>str</i>, int <i>pos</i> ) const</li>
 
40
<li><div class="fn"/>int <b><a href="qfontmetrics.html#descent">descent</a></b> () const</li>
 
41
<li><div class="fn"/>int <b><a href="qfontmetrics.html#height">height</a></b> () const</li>
 
42
<li><div class="fn"/>bool <b><a href="qfontmetrics.html#inFont">inFont</a></b> ( QChar <i>ch</i> ) const</li>
 
43
<li><div class="fn"/>int <b><a href="qfontmetrics.html#leading">leading</a></b> () const</li>
 
44
<li><div class="fn"/>int <b><a href="qfontmetrics.html#leftBearing">leftBearing</a></b> ( QChar <i>ch</i> ) const</li>
 
45
<li><div class="fn"/>int <b><a href="qfontmetrics.html#lineSpacing">lineSpacing</a></b> () const</li>
 
46
<li><div class="fn"/>int <b><a href="qfontmetrics.html#lineWidth">lineWidth</a></b> () const</li>
 
47
<li><div class="fn"/>int <b><a href="qfontmetrics.html#maxWidth">maxWidth</a></b> () const</li>
 
48
<li><div class="fn"/>int <b><a href="qfontmetrics.html#minLeftBearing">minLeftBearing</a></b> () const</li>
 
49
<li><div class="fn"/>int <b><a href="qfontmetrics.html#minRightBearing">minRightBearing</a></b> () const</li>
 
50
<li><div class="fn"/>int <b><a href="qfontmetrics.html#overlinePos">overlinePos</a></b> () const</li>
 
51
<li><div class="fn"/>int <b><a href="qfontmetrics.html#rightBearing">rightBearing</a></b> ( QChar <i>ch</i> ) const</li>
 
52
<li><div class="fn"/>QSize <b><a href="qfontmetrics.html#size">size</a></b> ( int <i>flgs</i>, const QString &amp; <i>text</i>, int <i>tabstops</i> = 0, int * <i>tabarray</i> = 0 ) const</li>
 
53
<li><div class="fn"/>int <b><a href="qfontmetrics.html#strikeOutPos">strikeOutPos</a></b> () const</li>
 
54
<li><div class="fn"/>int <b><a href="qfontmetrics.html#underlinePos">underlinePos</a></b> () const</li>
 
55
<li><div class="fn"/>int <b><a href="qfontmetrics.html#width">width</a></b> ( const QString &amp; <i>str</i>, int <i>len</i> = -1 ) const</li>
 
56
<li><div class="fn"/>int <b><a href="qfontmetrics.html#width-2">width</a></b> ( QChar <i>ch</i> ) const</li>
 
57
<li><div class="fn"/>bool <b><a href="qfontmetrics.html#operator-not-eq">operator!=</a></b> ( const QFontMetrics &amp; <i>other</i> )</li>
 
58
<li><div class="fn"/>QFontMetrics &amp; <b><a href="qfontmetrics.html#operator-eq">operator=</a></b> ( const QFontMetrics &amp; <i>fm</i> )</li>
 
59
<li><div class="fn"/>bool <b><a href="qfontmetrics.html#operator-eq-eq">operator==</a></b> ( const QFontMetrics &amp; <i>other</i> )</li>
 
60
</ul>
 
61
<a name="details"></a>
 
62
<hr />
 
63
<h2>Detailed Description</h2>
 
64
<p>The QFontMetrics class provides font metrics information.</p>
 
65
<p>QFontMetrics functions calculate the size of characters and strings for a given font. There are three ways you can create a QFontMetrics object:</p>
 
66
<ol type="1">
 
67
<li>Calling the QFontMetrics constructor with a <a href="qfont.html">QFont</a> creates a font metrics object for a screen-compatible font, i.e. the font cannot be a printer font. If the font is changed later, the font metrics object is <i>not</i> updated.<p>(Note: If you use a printer font the values returned may be inaccurate. Printer fonts are not always accessible so the nearest screen font is used if a printer font is supplied.)</p>
 
68
</li>
 
69
<li><a href="qwidget.html#fontMetrics">QWidget::fontMetrics</a>() returns the font metrics for a widget's font. This is equivalent to QFontMetrics(widget-&gt;font()). If the widget's font is changed later, the font metrics object is <i>not</i> updated.</li>
 
70
<li><a href="qpainter.html#fontMetrics">QPainter::fontMetrics</a>() returns the font metrics for a painter's current font. If the painter's font is changed later, the font metrics object is <i>not</i> updated.</li>
 
71
</ol>
 
72
<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>
 
73
<p>There are several functions that operate on the font: <a href="qfontmetrics.html#ascent">ascent</a>(), <a href="qfontmetrics.html#descent">descent</a>(), <a href="qfontmetrics.html#height">height</a>(), <a href="qfontmetrics.html#leading">leading</a>() and <a href="qfontmetrics.html#lineSpacing">lineSpacing</a>() return the basic size properties of the font. The <a href="qfontmetrics.html#underlinePos">underlinePos</a>(), <a href="qfontmetrics.html#overlinePos">overlinePos</a>(), <a href="qfontmetrics.html#strikeOutPos">strikeOutPos</a>() and <a href="qfontmetrics.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>
 
74
<p>There are also some functions that operate on the set of glyphs in the font: <a href="qfontmetrics.html#minLeftBearing">minLeftBearing</a>(), <a href="qfontmetrics.html#minRightBearing">minRightBearing</a>() and <a href="qfontmetrics.html#maxWidth">maxWidth</a>(). These are by necessity slow, and we recommend avoiding them if possible.</p>
 
75
<p>For each character, you can get its <a href="qfontmetrics.html#width">width</a>(), <a href="qfontmetrics.html#leftBearing">leftBearing</a>() and <a href="qfontmetrics.html#rightBearing">rightBearing</a>() and find out whether it is in the font using <a href="qfontmetrics.html#inFont">inFont</a>(). You can also treat the character as a string, and use the string functions on it.</p>
 
76
<p>The string functions include <a href="qfontmetrics.html#width">width</a>(), to return the width of a string in pixels (or points, for a printer), <a href="qfontmetrics.html#boundingRect">boundingRect</a>(), to return a rectangle large enough to contain the rendered string, and <a href="qfontmetrics.html#size">size</a>(), to return the size of that rectangle.</p>
 
77
<p>Example:</p>
 
78
<pre>&nbsp;   QFont font(&quot;times&quot;, 24);
 
79
    QFontMetrics fm(font);
 
80
    int pixelsWide = fm.width(&quot;What's the width of this text?&quot;);
 
81
    int pixelsHigh = fm.height();</pre>
 
82
<p>See also <a href="qfont.html">QFont</a>, <a href="qfontinfo.html">QFontInfo</a>, and <a href="qfontdatabase.html">QFontDatabase</a>.</p>
 
83
<hr />
 
84
<h2>Member Function Documentation</h2>
 
85
<h3 class="fn"><a name="QFontMetrics"></a>QFontMetrics::QFontMetrics ( const <a href="qfont.html">QFont</a> &amp; <i>font</i> )</h3>
 
86
<p>Constructs a font metrics object for <i>font</i>.</p>
 
87
<p>The font metrics will be compatible with the paintdevice used to create <i>font</i>.</p>
 
88
<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>
 
89
<p>Use <a href="qfontmetrics.html">QFontMetrics</a>(const <a href="qfont.html">QFont</a> &amp;, <a href="qpaintdevice.html">QPaintDevice</a> *) to get the font metrics that are compatible with a certain paint device.</p>
 
90
<h3 class="fn"><a name="QFontMetrics-2"></a>QFontMetrics::QFontMetrics ( const <a href="qfont.html">QFont</a> &amp; <i>font</i>, <a href="qpaintdevice.html">QPaintDevice</a> * <i>paintdevice</i> )</h3>
 
91
<p>Constructs a font metrics object for <i>font</i> and <i>paintdevice</i>.</p>
 
92
<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>
 
93
<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>
 
94
<h3 class="fn"><a name="QFontMetrics-3"></a>QFontMetrics::QFontMetrics ( const QFontMetrics &amp; <i>fm</i> )</h3>
 
95
<p>Constructs a copy of <i>fm</i>.</p>
 
96
<h3 class="fn"><a name="dtor.QFontMetrics"></a>QFontMetrics::~QFontMetrics ()</h3>
 
97
<p>Destroys the font metrics object and frees all allocated resources.</p>
 
98
<h3 class="fn"><a name="ascent"></a>int QFontMetrics::ascent () const</h3>
 
99
<p>Returns the ascent of the font.</p>
 
100
<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>
 
101
<p>See also <a href="qfontmetrics.html#descent">descent</a>().</p>
 
102
<h3 class="fn"><a name="boundingRect"></a><a href="qrect.html">QRect</a> QFontMetrics::boundingRect ( <a href="qchar.html">QChar</a> <i>ch</i> ) const</h3>
 
103
<p>Returns the bounding rectangle of the character <i>ch</i> relative to the left-most point on the base line.</p>
 
104
<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>
 
105
<p>Note that the rectangle usually extends both above and below the base line.</p>
 
106
<p>See also <a href="qfontmetrics.html#width">width</a>().</p>
 
107
<h3 class="fn"><a name="boundingRect-2"></a><a href="qrect.html">QRect</a> QFontMetrics::boundingRect ( const <a href="qstring.html">QString</a> &amp; <i>str</i> ) const</h3>
 
108
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
109
<p>Returns the bounding rectangle of the characters in the string specified by <i>str</i>, which is the set of pixels the text would cover if drawn at (0, 0).</p>
 
110
<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>
 
111
<p>Newline characters are processed as normal characters, <i>not</i> as linebreaks.</p>
 
112
<p>Due to the different actual character heights, the height of the bounding rectangle of e.g. &quot;Yes&quot; and &quot;yes&quot; may be different.</p>
 
113
<p>See also <a href="qfontmetrics.html#width">width</a>() and <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>().</p>
 
114
<h3 class="fn"><a name="boundingRect-5"></a><a href="qrect.html">QRect</a> QFontMetrics::boundingRect ( int <i>x</i>, int <i>y</i>, int <i>width</i>, int <i>height</i>, int <i>flags</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, int <i>tabstops</i> = 0, int * <i>tabarray</i> = 0 ) const</h3>
 
115
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
116
<p>Returns the bounding rectangle for the given <i>text</i> within the rectangle specified by the <i>x</i> and <i>y</i> coordinates, <i>width</i>, and <i>height</i>.</p>
 
117
<p>If <tt>Qt::TextExpandTabs</tt> is set in <i>flags</i> and <i>tabarray</i> is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise, if <i>tabstops</i> is non-zero, it is used as the tab spacing (in pixels).</p>
 
118
<h3 class="fn"><a name="boundingRect-6"></a><a href="qrect.html">QRect</a> QFontMetrics::boundingRect ( const <a href="qrect.html">QRect</a> &amp; <i>r</i>, int <i>flgs</i>, const <a href="qstring.html">QString</a> &amp; <i>str</i>, int <i>tabstops</i> = 0, int * <i>tabarray</i> = 0 ) const</h3>
 
119
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
120
<p>Returns the bounding rectangle of the characters in the string specified by <i>str</i>, which is the set of pixels the text would cover if drawn at (0, 0). The drawing, and hence the bounding rectangle, is constrained to the rectangle <i>r</i>.</p>
 
121
<p>The <i>flgs</i> argument is the bitwise OR of the following flags:</p>
 
122
<ul>
 
123
<li><tt>Qt::AlignLeft</tt> aligns to the left border, except for Arabic and Hebrew where it aligns to the right.</li>
 
124
<li><tt>Qt::AlignRight</tt> aligns to the right border, except for Arabic and Hebrew where it aligns to the left.</li>
 
125
<li><tt>Qt::AlignJustify</tt> produces justified text.</li>
 
126
<li><tt>Qt::AlignHCenter</tt> aligns horizontally centered.</li>
 
127
<li><tt>Qt::AlignTop</tt> aligns to the top border.</li>
 
128
<li><tt>Qt::AlignBottom</tt> aligns to the bottom border.</li>
 
129
<li><tt>Qt::AlignVCenter</tt> aligns vertically centered</li>
 
130
<li><tt>Qt::AlignCenter</tt> (== <tt>Qt::AlignHCenter | Qt::AlignVCenter</tt>)</li>
 
131
<li><tt>Qt::TextSingleLine</tt> ignores newline characters in the text.</li>
 
132
<li><tt>Qt::TextExpandTabs</tt> expands tabs (see below)</li>
 
133
<li><tt>Qt::TextShowMnemonic</tt> interprets &quot;&amp;amp;x&quot; as <u>x</u>, i.e. underlined.</li>
 
134
<li><tt>Qt::TextWordBreak</tt> breaks the text to fit the rectangle.</li>
 
135
</ul>
 
136
<p><a href="qt.html#Orientation-enum">Qt::Horizontal</a> alignment defaults to <tt>Qt::AlignLeft</tt> and vertical alignment defaults to <tt>Qt::AlignTop</tt>.</p>
 
137
<p>If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.</p>
 
138
<p>These flags are defined in <tt>qnamespace.h</tt>.</p>
 
139
<p>If <tt>Qt::TextExpandTabs</tt> is set in <i>flgs</i>, then: if <i>tabarray</i> is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise if <i>tabstops</i> is non-zero, it is used as the tab spacing (in pixels).</p>
 
140
<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>
 
141
<p>Newline characters are processed as linebreaks.</p>
 
142
<p>Despite the different actual character heights, the heights of the bounding rectangles of &quot;Yes&quot; and &quot;yes&quot; are the same.</p>
 
143
<p>The bounding rectangle returned by this function is somewhat larger than that calculated by the simpler <a href="qfontmetrics.html#boundingRect">boundingRect</a>() function. This function uses the <a href="qfontmetrics.html#minLeftBearing">maximum left</a> and <a href="qfontmetrics.html#minRightBearing">right</a> font bearings as is necessary for multi-line text to align correctly. Also, fontHeight() and <a href="qfontmetrics.html#lineSpacing">lineSpacing</a>() are used to calculate the height, rather than individual character heights.</p>
 
144
<p>See also <a href="qfontmetrics.html#width">width</a>(), <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>(), and <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a>.</p>
 
145
<h3 class="fn"><a name="charWidth"></a>int QFontMetrics::charWidth ( const <a href="qstring.html">QString</a> &amp; <i>str</i>, int <i>pos</i> ) const</h3>
 
146
<p>Returns the width of the character at position <i>pos</i> in the string <i>str</i>.</p>
 
147
<p>The whole string is needed, as the glyph drawn may change depending on the context (the letter before and after the current one) for some languages (e.g. Arabic).</p>
 
148
<p>This function also takes non spacing marks and ligatures into account.</p>
 
149
<h3 class="fn"><a name="descent"></a>int QFontMetrics::descent () const</h3>
 
150
<p>Returns the descent of the font.</p>
 
151
<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>
 
152
<p>See also <a href="qfontmetrics.html#ascent">ascent</a>().</p>
 
153
<h3 class="fn"><a name="height"></a>int QFontMetrics::height () const</h3>
 
154
<p>Returns the height of the font.</p>
 
155
<p>This is always equal to <a href="qfontmetrics.html#ascent">ascent</a>()+<a href="qfontmetrics.html#descent">descent</a>()+1 (the 1 is for the base line).</p>
 
156
<p>See also <a href="qfontmetrics.html#leading">leading</a>() and <a href="qfontmetrics.html#lineSpacing">lineSpacing</a>().</p>
 
157
<h3 class="fn"><a name="inFont"></a>bool QFontMetrics::inFont ( <a href="qchar.html">QChar</a> <i>ch</i> ) const</h3>
 
158
<p>Returns true if character <i>ch</i> is a valid character in the font; otherwise returns false.</p>
 
159
<h3 class="fn"><a name="leading"></a>int QFontMetrics::leading () const</h3>
 
160
<p>Returns the leading of the font.</p>
 
161
<p>This is the natural inter-line spacing.</p>
 
162
<p>See also <a href="qfontmetrics.html#height">height</a>() and <a href="qfontmetrics.html#lineSpacing">lineSpacing</a>().</p>
 
163
<h3 class="fn"><a name="leftBearing"></a>int QFontMetrics::leftBearing ( <a href="qchar.html">QChar</a> <i>ch</i> ) const</h3>
 
164
<p>Returns the left bearing of character <i>ch</i> in the font.</p>
 
165
<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>
 
166
<p>See width(<a href="qchar.html">QChar</a>) for a graphical description of this metric.</p>
 
167
<p>See also <a href="qfontmetrics.html#rightBearing">rightBearing</a>(), <a href="qfontmetrics.html#minLeftBearing">minLeftBearing</a>(), and <a href="qfontmetrics.html#width">width</a>().</p>
 
168
<h3 class="fn"><a name="lineSpacing"></a>int QFontMetrics::lineSpacing () const</h3>
 
169
<p>Returns the distance from one base line to the next.</p>
 
170
<p>This value is always equal to <a href="qfontmetrics.html#leading">leading</a>()+<a href="qfontmetrics.html#height">height</a>().</p>
 
171
<p>See also <a href="qfontmetrics.html#height">height</a>() and <a href="qfontmetrics.html#leading">leading</a>().</p>
 
172
<h3 class="fn"><a name="lineWidth"></a>int QFontMetrics::lineWidth () const</h3>
 
173
<p>Returns the width of the underline and strikeout lines, adjusted for the point size of the font.</p>
 
174
<p>See also <a href="qfontmetrics.html#underlinePos">underlinePos</a>(), <a href="qfontmetrics.html#overlinePos">overlinePos</a>(), and <a href="qfontmetrics.html#strikeOutPos">strikeOutPos</a>().</p>
 
175
<h3 class="fn"><a name="maxWidth"></a>int QFontMetrics::maxWidth () const</h3>
 
176
<p>Returns the width of the widest character in the font.</p>
 
177
<h3 class="fn"><a name="minLeftBearing"></a>int QFontMetrics::minLeftBearing () const</h3>
 
178
<p>Returns the minimum left bearing of the font.</p>
 
179
<p>This is the smallest leftBearing(char) of all characters in the font.</p>
 
180
<p>Note that this function can be very slow if the font is large.</p>
 
181
<p>See also <a href="qfontmetrics.html#minRightBearing">minRightBearing</a>() and <a href="qfontmetrics.html#leftBearing">leftBearing</a>().</p>
 
182
<h3 class="fn"><a name="minRightBearing"></a>int QFontMetrics::minRightBearing () const</h3>
 
183
<p>Returns the minimum right bearing of the font.</p>
 
184
<p>This is the smallest rightBearing(char) of all characters in the font.</p>
 
185
<p>Note that this function can be very slow if the font is large.</p>
 
186
<p>See also <a href="qfontmetrics.html#minLeftBearing">minLeftBearing</a>() and <a href="qfontmetrics.html#rightBearing">rightBearing</a>().</p>
 
187
<h3 class="fn"><a name="overlinePos"></a>int QFontMetrics::overlinePos () const</h3>
 
188
<p>Returns the distance from the base line to where an overline should be drawn.</p>
 
189
<p>See also <a href="qfontmetrics.html#underlinePos">underlinePos</a>(), <a href="qfontmetrics.html#strikeOutPos">strikeOutPos</a>(), and <a href="qfontmetrics.html#lineWidth">lineWidth</a>().</p>
 
190
<h3 class="fn"><a name="rightBearing"></a>int QFontMetrics::rightBearing ( <a href="qchar.html">QChar</a> <i>ch</i> ) const</h3>
 
191
<p>Returns the right bearing of character <i>ch</i> in the font.</p>
 
192
<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="qfontmetrics.html#width">width</a>() of the character.</p>
 
193
<p>See <a href="qfontmetrics.html#width">width</a>() for a graphical description of this metric.</p>
 
194
<p>See also <a href="qfontmetrics.html#leftBearing">leftBearing</a>(), <a href="qfontmetrics.html#minRightBearing">minRightBearing</a>(), and <a href="qfontmetrics.html#width">width</a>().</p>
 
195
<h3 class="fn"><a name="size"></a><a href="qsize.html">QSize</a> QFontMetrics::size ( int <i>flgs</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, int <i>tabstops</i> = 0, int * <i>tabarray</i> = 0 ) const</h3>
 
196
<p>Returns the size in pixels of <i>text</i>.</p>
 
197
<p>The <i>flgs</i> argument is the bitwise OR of the following flags:</p>
 
198
<ul>
 
199
<li><tt>Qt::TextSingleLine</tt> ignores newline characters.</li>
 
200
<li><tt>Qt::TextExpandTabs</tt> expands tabs (see below)</li>
 
201
<li><tt>Qt::TextShowMnemonic</tt> interprets &quot;&amp;amp;x&quot; as <u>x</u>, i.e. underlined.</li>
 
202
<li><tt>Qt::TextWordBreak</tt> breaks the text to fit the rectangle.</li>
 
203
</ul>
 
204
<p>These flags are defined in <tt>qnamespace.h</tt>.</p>
 
205
<p>If <tt>Qt::TextExpandTabs</tt> is set in <i>flgs</i>, then: if <i>tabarray</i> is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise if <i>tabstops</i> is non-zero, it is used as the tab spacing (in pixels).</p>
 
206
<p>Newline characters are processed as linebreaks.</p>
 
207
<p>Despite the different actual character heights, the heights of the bounding rectangles of &quot;Yes&quot; and &quot;yes&quot; are the same.</p>
 
208
<p>See also <a href="qfontmetrics.html#boundingRect">boundingRect</a>().</p>
 
209
<h3 class="fn"><a name="strikeOutPos"></a>int QFontMetrics::strikeOutPos () const</h3>
 
210
<p>Returns the distance from the base line to where the strikeout line should be drawn.</p>
 
211
<p>See also <a href="qfontmetrics.html#underlinePos">underlinePos</a>(), <a href="qfontmetrics.html#overlinePos">overlinePos</a>(), and <a href="qfontmetrics.html#lineWidth">lineWidth</a>().</p>
 
212
<h3 class="fn"><a name="underlinePos"></a>int QFontMetrics::underlinePos () const</h3>
 
213
<p>Returns the distance from the base line to where an underscore should be drawn.</p>
 
214
<p>See also <a href="qfontmetrics.html#overlinePos">overlinePos</a>(), <a href="qfontmetrics.html#strikeOutPos">strikeOutPos</a>(), and <a href="qfontmetrics.html#lineWidth">lineWidth</a>().</p>
 
215
<h3 class="fn"><a name="width"></a>int QFontMetrics::width ( const <a href="qstring.html">QString</a> &amp; <i>str</i>, int <i>len</i> = -1 ) const</h3>
 
216
<p>Returns the width in pixels of the first <i>len</i> characters of <i>str</i>. If <i>len</i> is negative (the default), the entire string is used.</p>
 
217
<p>Note that this value is <i>not</i> equal to <a href="qfontmetrics.html#boundingRect">boundingRect</a>().width(); <a href="qfontmetrics.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>
 
218
<p>See also <a href="qfontmetrics.html#boundingRect">boundingRect</a>().</p>
 
219
<h3 class="fn"><a name="width-2"></a>int QFontMetrics::width ( <a href="qchar.html">QChar</a> <i>ch</i> ) const</h3>
 
220
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
221
<center><img src="images/bearings.png" alt="Bearings" /></center><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>
 
222
<p>Some of the metrics are described in the image to the right. The central dark rectangles cover the logical <a href="qfontmetrics.html#width">width</a>() of each character. The outer pale rectangles cover the <a href="qfontmetrics.html#leftBearing">leftBearing</a>() and <a href="qfontmetrics.html#rightBearing">rightBearing</a>() of each character. Notice that the bearings of &quot;f&quot; in this particular font are both negative, while the bearings of &quot;o&quot; are both positive.</p>
 
223
<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. Use <a href="qfontmetrics.html#charWidth">charWidth</a>() instead if you aren't looking for the width of isolated characters.</p>
 
224
<p>See also <a href="qfontmetrics.html#boundingRect">boundingRect</a>() and <a href="qfontmetrics.html#charWidth">charWidth</a>().</p>
 
225
<h3 class="fn"><a name="operator-not-eq"></a>bool QFontMetrics::operator!= ( const QFontMetrics &amp; <i>other</i> )</h3>
 
226
<p>Returns true if <i>other</i> is not equal to this object; otherwise returns false.</p>
 
227
<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 compatible.</p>
 
228
<p>See also <a href="qfontmetrics.html#operator-eq-eq">operator==</a>().</p>
 
229
<h3 class="fn"><a name="operator-eq"></a>QFontMetrics &amp; QFontMetrics::operator= ( const QFontMetrics &amp; <i>fm</i> )</h3>
 
230
<p>Assigns the font metrics <i>fm</i>.</p>
 
231
<h3 class="fn"><a name="operator-eq-eq"></a>bool QFontMetrics::operator== ( const QFontMetrics &amp; <i>other</i> )</h3>
 
232
<p>Returns true if <i>other</i> is equal to this object; otherwise returns false.</p>
 
233
<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 compatible.</p>
 
234
<p>See also <a href="qfontmetrics.html#operator-not-eq">operator!=</a>().</p>
 
235
<p /><address><hr /><div align="center">
 
236
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
237
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
238
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
239
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
240
</tr></table></div></address></body>
 
241
</html>