📄 qfontmetrics.3qt
字号:
.TP\fCExpandTabs\fR expands tabs (see below).TP\fCShowPrefix\fR interprets "&x" as "<u>x</u>", i.e. underlined..TP\fCWordBreak\fR breaks the text to fit the rectangle..PPHorizontal alignment defaults to \fCAlignAuto\fR and vertical alignment defaults to \fCAlignTop\fR..PPIf several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined..PPThese flags are defined in qnamespace.h..PPIf \fCExpandTabs\fR is set in \fIflgs\fR, then: if \fItabarray\fR is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise if \fItabstops\fR is non-zero, it is used as the tab spacing (in pixels)..PPNote that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the text output may cover \fIall\fR pixels in the bounding rectangle..PPNewline characters are processed as linebreaks..PPDespite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same..PPThe bounding rectangle given by this function is somewhat larger than that calculated by the simpler boundingRect() function. This function uses the maximum left and right font bearings as is necessary for multi-line text to align correctly. Also, fontHeight() and lineSpacing() are used to calculate the height, rather than individual character heights..PPThe \fIintern\fR argument should not be used..PPSee also width(), QPainter::boundingRect(), and Qt::AlignmentFlags..SH "int QFontMetrics::charWidth ( const QString & str, int pos ) const"Returns the width of the character at position \fIpos\fR in the string \fIstr\fR..PPThe 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)..PPThis function also takes non spacing marks and ligatures into account..SH "int QFontMetrics::descent () const"Returns the descent of the font..PPThe 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..PPSee also ascent()..PPExamples:.)l drawdemo/drawdemo.cpp and hello/hello.cpp..SH "int QFontMetrics::height () const"Returns the height of the font..PPThis is always equal to ascent()+descent()+1 (the 1 is for the base line)..PPSee also leading() and lineSpacing()..PPExamples:.)l hello/hello.cpp and qfd/fontdisplayer.cpp..SH "bool QFontMetrics::inFont ( QChar ch ) const"Returns TRUE if character \fIch\fR is a valid character in the font; otherwise returns FALSE..PPExample: qfd/fontdisplayer.cpp..SH "int QFontMetrics::leading () const"Returns the leading of the font..PPThis is the natural inter-line spacing..PPSee also height() and lineSpacing()..SH "int QFontMetrics::leftBearing ( QChar ch ) const"Returns the left bearing of character \fIch\fR in the font..PPThe 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..PPSee width(QChar) for a graphical description of this metric..PPSee also rightBearing(), minLeftBearing(), and width()..PPExample: qfd/fontdisplayer.cpp..SH "int QFontMetrics::lineSpacing () const"Returns the distance from one base line to the next..PPThis value is always equal to leading()+height()..PPSee also height() and leading()..PPExamples:.)l action/application.cpp, application/application.cpp, mdi/application.cpp, qfd/fontdisplayer.cpp, qwerty/qwerty.cpp, and scrollview/scrollview.cpp..SH "int QFontMetrics::lineWidth () const"Returns the width of the underline and strikeout lines, adjusted for the point size of the font..PPSee also underlinePos() and strikeOutPos()..SH "int QFontMetrics::maxWidth () const"Returns the width of the widest character in the font..PPExample: qfd/fontdisplayer.cpp..SH "int QFontMetrics::minLeftBearing () const"Returns the minimum left bearing of the font..PPThis is the smallest leftBearing(char) of all characters in the font..PPNote that this function can be very slow if the font is large..PPSee also minRightBearing() and leftBearing()..PPExample: qfd/fontdisplayer.cpp..SH "int QFontMetrics::minRightBearing () const"Returns the minimum right bearing of the font..PPThis is the smallest rightBearing(char) of all characters in the font..PPNote that this function can be very slow if the font is large..PPSee also minLeftBearing() and rightBearing()..PPExample: qfd/fontdisplayer.cpp..SH "QFontMetrics & QFontMetrics::operator= ( const QFontMetrics & fm )"Assigns the font metrics \fIfm\fR..SH "int QFontMetrics::rightBearing ( QChar ch ) const"Returns the right bearing of character \fIch\fR in the font..PPThe 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 width() of the character..PPSee width() for a graphical description of this metric..PPSee also leftBearing(), minRightBearing(), and width()..PPExample: qfd/fontdisplayer.cpp..SH "QSize QFontMetrics::size ( int flgs, const QString & str, int len = -1, int tabstops = 0, int * tabarray = 0, QTextParag ** intern = 0 ) const"Returns the size in pixels of the first \fIlen\fR characters of \fIstr\fR..PPIf \fIlen\fR is negative (the default), the entire string is used..PPThe \fIflgs\fR argument is the bitwise OR of the following flags:.TP\fCSingleLine\fR ignores newline characters..TP\fCExpandTabs\fR expands tabs (see below).TP\fCShowPrefix\fR interprets "&x" as "<u>x</u>", i.e. underlined..TP\fCWordBreak\fR breaks the text to fit the rectangle..PPThese flags are defined in qnamespace.h..PPIf \fCExpandTabs\fR is set in \fIflgs\fR, then: if \fItabarray\fR is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise if \fItabstops\fR is non-zero, it is used as the tab spacing (in pixels)..PPNewline characters are processed as linebreaks..PPDespite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same..PPThe \fIintern\fR argument should not be used..PPSee also boundingRect()..SH "int QFontMetrics::strikeOutPos () const"Returns the distance from the base line to where the strikeout line should be drawn..PPSee also underlinePos() and lineWidth()..SH "int QFontMetrics::underlinePos () const"Returns the distance from the base line to where an underscore should be drawn..PPSee also strikeOutPos() and lineWidth()..SH "int QFontMetrics::width ( const QString & str, int len = -1 ) const"Returns the width in pixels of the first \fIlen\fR characters of \fIstr\fR. If \fIlen\fR is negative (the default), the entire string is used..PPNote that this value is \fInot\fR equal to boundingRect().width(); boundingRect() returns a rectangle describing the pixels this string will cover whereas width() returns the distance to where the next string should be drawn..PPSee also boundingRect()..PPExamples:.)l drawdemo/drawdemo.cpp, hello/hello.cpp, movies/main.cpp, qfd/fontdisplayer.cpp, and scrollview/scrollview.cpp..SH "int QFontMetrics::width ( QChar ch ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP.ce 1.B "[Image Omitted]".PPReturns the logical width of character \fIch\fR in pixels. This is a distance appropriate for drawing a subsequent character after \fIch\fR..PPSome of the metrics are described in the image to the right. The central dark rectangles cover the logical width() of each character. The outer pale rectangles cover the leftBearing() and rightBearing() of each character. Notice that the bearings of "f" in this particular font are both negative, while the bearings of" o" are both positive..PP\fBWarning:\fR 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 charWidth() instead if you aren't looking for the width of isolated characters..PPSee also boundingRect() and charWidth()..SH "int QFontMetrics::width ( char c ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPProvided to aid porting from Qt 1.x..SH "SEE ALSO".BR http://doc.trolltech.com/qfontmetrics.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qfontmetrics.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -