File: qfontmetrics.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (118 lines) | stat: -rw-r--r-- 24,094 bytes parent folder | download
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QFontMetrics Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QFontMetrics Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QFontMetrics class provides font metrics information. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qfontmetrics.html#QFontMetrics">__init__</a></b> (<i>self</i>, QFont)</li><li><div class="fn" /><b><a href="qfontmetrics.html#QFontMetrics-2">__init__</a></b> (<i>self</i>, QFont, QPaintDevice&#160;<i>pd</i>)</li><li><div class="fn" /><b><a href="qfontmetrics.html#QFontMetrics-3">__init__</a></b> (<i>self</i>, QFontMetrics)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#ascent">ascent</a></b> (<i>self</i>)</li><li><div class="fn" />QRect <b><a href="qfontmetrics.html#boundingRect">boundingRect</a></b> (<i>self</i>, QChar)</li><li><div class="fn" />QRect <b><a href="qfontmetrics.html#boundingRect-2">boundingRect</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" />QRect <b><a href="qfontmetrics.html#boundingRect-3">boundingRect</a></b> (<i>self</i>, QRect&#160;<i>r</i>, int&#160;<i>flags</i>, QString&#160;<i>text</i>, int&#160;<i>tabstops</i>&#160;=&#160;0, list&#160;<i>tabarray</i>&#160;=&#160;0)</li><li><div class="fn" />QRect <b><a href="qfontmetrics.html#boundingRect-4">boundingRect</a></b> (<i>self</i>, int&#160;<i>x</i>, int&#160;<i>y</i>, int&#160;<i>w</i>, int&#160;<i>h</i>, int&#160;<i>flags</i>, QString&#160;<i>text</i>, int&#160;<i>tabstops</i>&#160;=&#160;0, list&#160;<i>tabarray</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#charWidth">charWidth</a></b> (<i>self</i>, QString&#160;<i>str</i>, int&#160;<i>pos</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#descent">descent</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#height">height</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qfontmetrics.html#inFont">inFont</a></b> (<i>self</i>, QChar)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#leading">leading</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#leftBearing">leftBearing</a></b> (<i>self</i>, QChar)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#lineSpacing">lineSpacing</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#lineWidth">lineWidth</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#maxWidth">maxWidth</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#minLeftBearing">minLeftBearing</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#minRightBearing">minRightBearing</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#overlinePos">overlinePos</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#rightBearing">rightBearing</a></b> (<i>self</i>, QChar)</li><li><div class="fn" />QSize <b><a href="qfontmetrics.html#size">size</a></b> (<i>self</i>, int&#160;<i>flags</i>, QString&#160;<i>str</i>, int&#160;<i>tabstops</i>&#160;=&#160;0, list&#160;<i>tabarray</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#strikeOutPos">strikeOutPos</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#underlinePos">underlinePos</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#width">width</a></b> (<i>self</i>, QString, int&#160;<i>len</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#width-2">width</a></b> (<i>self</i>, QChar)</li><li><div class="fn" />int <b><a href="qfontmetrics.html#xHeight">xHeight</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qfontmetrics.html#__eq__">__eq__</a></b> (<i>self</i>, QFontMetrics&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qfontmetrics.html#__ne__">__ne__</a></b> (<i>self</i>, QFontMetrics&#160;<i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QFontMetrics class provides font metrics information.</p>
<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>
<ol type="1">
<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>
</li>
<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>
<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>
</ol>
<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="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>
<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>
<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>
<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>
<p>Example:</p>
<pre>
    QFont font("times", 24);
    QFontMetrics fm(font);
    int pixelsWide = fm.width("What's the width of this text?");
    int pixelsHigh = fm.height();
</pre>
<p>See also <a href="qfont.html">QFont</a>, <a href="qfontinfo.html">QFontInfo</a>, and <a href="qfontdatabase.html">QFontDatabase</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QFontMetrics" />QFontMetrics.__init__ (<i>self</i>, <a href="qfont.html">QFont</a>)</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="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>
<h3 class="fn"><a name="QFontMetrics-2" />QFontMetrics.__init__ (<i>self</i>, <a href="qfont.html">QFont</a>, <a href="qpaintdevice.html">QPaintDevice</a>&#160;<i>pd</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>
<h3 class="fn"><a name="QFontMetrics-3" />QFontMetrics.__init__ (<i>self</i>, <a href="qfontmetrics.html">QFontMetrics</a>)</h3><p>Constructs a copy of <i>fm</i>.</p>
<h3 class="fn"><a name="ascent" />int QFontMetrics.ascent (<i>self</i>)</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>See also <a href="qfontmetrics.html#descent">descent</a>().</p>
<h3 class="fn"><a name="boundingRect" /><a href="qrect.html">QRect</a> QFontMetrics.boundingRect (<i>self</i>, <a href="qchar.html">QChar</a>)</h3><p>Returns the rectangle that is covered by ink if the character where to be drawn at the origin of the coordinate system.</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. For a space character the rectangle will usually be empty.</p>
<p>Note that the rectangle usually extends both above and below the base line.</p>
<p><b>Warning:</b> The width of the returned rectangle is not the advance width of the character. Use boundingRect(const <a href="qstring.html">QString</a> &amp;) or <a href="qfontmetrics.html#width">width</a>() instead.</p>
<p>See also <a href="qfontmetrics.html#width">width</a>().</p>
<h3 class="fn"><a name="boundingRect-2" /><a href="qrect.html">QRect</a> QFontMetrics.boundingRect (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<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>
<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>Newline characters are processed as normal characters, <i>not</i> as linebreaks.</p>
<p>Due to the different actual character heights, the height of the bounding rectangle of e.g. "Yes" and "yes" may be different.</p>
<p>See also <a href="qfontmetrics.html#width">width</a>() and <a href="qpainter.html#boundingRect">QPainter.boundingRect</a>().</p>
<h3 class="fn"><a name="boundingRect-3" /><a href="qrect.html">QRect</a> QFontMetrics.boundingRect (<i>self</i>, <a href="qrect.html">QRect</a>&#160;<i>r</i>, int&#160;<i>flags</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, int&#160;<i>tabstops</i>&#160;=&#160;0, list&#160;<i>tabarray</i>&#160;=&#160;0)</h3><p>The <i>tabarray</i> argument may also be None.</p><h3 class="fn"><a name="boundingRect-4" /><a href="qrect.html">QRect</a> QFontMetrics.boundingRect (<i>self</i>, int&#160;<i>x</i>, int&#160;<i>y</i>, int&#160;<i>w</i>, int&#160;<i>h</i>, int&#160;<i>flags</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, int&#160;<i>tabstops</i>&#160;=&#160;0, list&#160;<i>tabarray</i>&#160;=&#160;0)</h3><p>The <i>tabarray</i> argument may also be None.</p><h3 class="fn"><a name="charWidth" />int QFontMetrics.charWidth (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>str</i>, int&#160;<i>pos</i>)</h3><p>Returns the width of the character at position <i>pos</i> in the string <i>str</i>.</p>
<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>
<p>This function also takes non spacing marks and ligatures into account.</p>
<h3 class="fn"><a name="descent" />int QFontMetrics.descent (<i>self</i>)</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>See also <a href="qfontmetrics.html#ascent">ascent</a>().</p>
<h3 class="fn"><a name="height" />int QFontMetrics.height (<i>self</i>)</h3><p>Returns the height of the font.</p>
<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>
<p>See also <a href="qfontmetrics.html#leading">leading</a>() and <a href="qfontmetrics.html#lineSpacing">lineSpacing</a>().</p>
<h3 class="fn"><a name="inFont" />bool QFontMetrics.inFont (<i>self</i>, <a href="qchar.html">QChar</a>)</h3><p>Returns true if character <i>ch</i> is a valid character in the font; otherwise returns false.</p>
<h3 class="fn"><a name="leading" />int QFontMetrics.leading (<i>self</i>)</h3><p>Returns the leading of the font.</p>
<p>This is the natural inter-line spacing.</p>
<p>See also <a href="qfontmetrics.html#height">height</a>() and <a href="qfontmetrics.html#lineSpacing">lineSpacing</a>().</p>
<h3 class="fn"><a name="leftBearing" />int QFontMetrics.leftBearing (<i>self</i>, <a href="qchar.html">QChar</a>)</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>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>
<h3 class="fn"><a name="lineSpacing" />int QFontMetrics.lineSpacing (<i>self</i>)</h3><p>Returns the distance from one base line to the next.</p>
<p>This value is always equal to <a href="qfontmetrics.html#leading">leading</a>()+<a href="qfontmetrics.html#height">height</a>().</p>
<p>See also <a href="qfontmetrics.html#height">height</a>() and <a href="qfontmetrics.html#leading">leading</a>().</p>
<h3 class="fn"><a name="lineWidth" />int QFontMetrics.lineWidth (<i>self</i>)</h3><p>Returns the width of the underline and strikeout lines, adjusted for the point size of the font.</p>
<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>
<h3 class="fn"><a name="maxWidth" />int QFontMetrics.maxWidth (<i>self</i>)</h3><p>Returns the width of the widest character in the font.</p>
<h3 class="fn"><a name="minLeftBearing" />int QFontMetrics.minLeftBearing (<i>self</i>)</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>See also <a href="qfontmetrics.html#minRightBearing">minRightBearing</a>() and <a href="qfontmetrics.html#leftBearing">leftBearing</a>().</p>
<h3 class="fn"><a name="minRightBearing" />int QFontMetrics.minRightBearing (<i>self</i>)</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>See also <a href="qfontmetrics.html#minLeftBearing">minLeftBearing</a>() and <a href="qfontmetrics.html#rightBearing">rightBearing</a>().</p>
<h3 class="fn"><a name="overlinePos" />int QFontMetrics.overlinePos (<i>self</i>)</h3><p>Returns the distance from the base line to where an overline should be drawn.</p>
<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>
<h3 class="fn"><a name="rightBearing" />int QFontMetrics.rightBearing (<i>self</i>, <a href="qchar.html">QChar</a>)</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="qfontmetrics.html#width">width</a>() of the character.</p>
<p>See <a href="qfontmetrics.html#width">width</a>() for a graphical description of this metric.</p>
<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>
<h3 class="fn"><a name="size" /><a href="qsize.html">QSize</a> QFontMetrics.size (<i>self</i>, int&#160;<i>flags</i>, <a href="qstring.html">QString</a>&#160;<i>str</i>, int&#160;<i>tabstops</i>&#160;=&#160;0, list&#160;<i>tabarray</i>&#160;=&#160;0)</h3><p>The <i>tabarray</i> argument may also be None.</p><p>Returns the size in pixels of <i>text</i>.</p>
<p>The <i>flgs</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 "&amp;amp;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 <tt>qnamespace.h</tt>.</p>
<p>If <a href="qt.html#TextFlag-enum">Qt.TextExpandTabs</a> 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>
<p>Newline characters are processed as linebreaks.</p>
<p>Despite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same.</p>
<p>See also <a href="qfontmetrics.html#boundingRect">boundingRect</a>().</p>
<h3 class="fn"><a name="strikeOutPos" />int QFontMetrics.strikeOutPos (<i>self</i>)</h3><p>Returns the distance from the base line to where the strikeout line should be drawn.</p>
<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>
<h3 class="fn"><a name="underlinePos" />int QFontMetrics.underlinePos (<i>self</i>)</h3><p>Returns the distance from the base line to where an underscore should be drawn.</p>
<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>
<h3 class="fn"><a name="width" />int QFontMetrics.width (<i>self</i>, <a href="qstring.html">QString</a>, int&#160;<i>len</i>&#160;=&#160;-1)</h3><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>
<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>
<p>See also <a href="qfontmetrics.html#boundingRect">boundingRect</a>().</p>
<h3 class="fn"><a name="width-2" />int QFontMetrics.width (<i>self</i>, <a href="qchar.html">QChar</a>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p align="center"><img alt="Bearings" src="images/bearings.png" /></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="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 "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. Use <a href="qfontmetrics.html#charWidth">charWidth</a>() instead if you aren't looking for the width of isolated characters.</p>
<p>See also <a href="qfontmetrics.html#boundingRect">boundingRect</a>() and <a href="qfontmetrics.html#charWidth">charWidth</a>().</p>
<h3 class="fn"><a name="xHeight" />int QFontMetrics.xHeight (<i>self</i>)</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>
<h3 class="fn"><a name="__eq__" />bool QFontMetrics.__eq__ (<i>self</i>, <a href="qfontmetrics.html">QFontMetrics</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QFontMetrics.__ne__ (<i>self</i>, <a href="qfontmetrics.html">QFontMetrics</a>&#160;<i>other</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>