qfontmetrics.3qt

来自「tmark1.11:用于生成QT/EMBEDDED应用工程的Markfile文件」· 3QT 代码 · 共 361 行

3QT
361
字号
.TH QFontMetrics 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQFontMetrics \- Font metrics information about fonts.SH SYNOPSIS.br.PP\fC#include <qfontmetrics.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQFontMetrics\fR ( const QFont & )".br.ti -1c.BI "\fBQFontMetrics\fR ( const QFontMetrics & )".br.ti -1c.BI "\fB~QFontMetrics\fR ()".br.ti -1c.BI "QFontMetrics& \fBoperator=\fR ( const QFontMetrics & )".br.ti -1c.BI "int \fBascent\fR () const".br.ti -1c.BI "int \fBdescent\fR () const".br.ti -1c.BI "int \fBheight\fR () const".br.ti -1c.BI "int \fBleading\fR () const".br.ti -1c.BI "int \fBlineSpacing\fR () const".br.ti -1c.BI "int \fBminLeftBearing\fR () const".br.ti -1c.BI "int \fBminRightBearing\fR () const".br.ti -1c.BI "int \fBmaxWidth\fR () const".br.ti -1c.BI "bool \fBinFont\fR ( QChar ) const".br.ti -1c.BI "int \fBleftBearing\fR ( QChar ) const".br.ti -1c.BI "int \fBrightBearing\fR ( QChar ) const".br.ti -1c.BI "int \fBwidth\fR ( const QString &, int " "len" " = -1 ) const".br.ti -1c.BI "int \fBwidth\fR ( QChar ) const".br.ti -1c.BI "int \fBwidth\fR ( char c ) const".br.ti -1c.BI "QRect \fBboundingRect\fR ( const QString &, int " "len" " = -1 ) const".br.ti -1c.BI "QRect \fBboundingRect\fR ( QChar ) const".br.ti -1c.BI "QRect \fBboundingRect\fR ( int " "x" ", int " "y" ", int " "w" ", int " "h" ", int " "flags" ", const QString & " "str" ", int " "len" "=-1, int " "tabstops" "=0, int * " "tabarray" "=0, char ** " "intern" "=0 ) const".br.ti -1c.BI "QSize \fBsize\fR ( int " "flags" ", const QString & " "str" ", int " "len" "=-1, int " "tabstops" "=0, int * " "tabarray" "=0, char ** " "intern" "=0 ) const".br.ti -1c.BI "int \fBunderlinePos\fR () const".br.ti -1c.BI "int \fBstrikeOutPos\fR () const".br.ti -1c.BI "int \fBlineWidth\fR () const".br.in -1c.SH DESCRIPTIONThe QFontMetrics class provides font metrics information about fonts..PPQFontMetrics functions calculate size of characters and strings for a given font..PPThere are three ways you can create a QFontMetrics object:.IP 1The QFontMetrics constructor with a QFont creates a font metrics object for a screen-compatible font, i.e. the font must not be a printer font..IP 2QWidget::fontMetrics() returns the font metrics for a widget's font. This is equivalent to QFontMetrics(widget->font()). Setting a new font for the widget later will not affect the font metrics object..IP 3QPainter::fontMetrics() returns the font metrics for a painter's current font. The font metrics object is automatically updated if somebody sets a new painter font (unlike the two above cases, which take a "snapshot" of a font)..PPExample:.PP.nf.br    QFont font("times",24);.br    QFontMetrics fm(font);.br    int w = fm.width("What's the width of this text");.br    int h = fm.height();.fi.PPSee also: QFont and QFontInfo..PPExamples:.(lgrapher/grapher.cpp xform/xform.cpp drawdemo/drawdemo.cpp scrollview/scrollview.cpp movies/main.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QFontMetrics::QFontMetrics ( const QFont & font )"Constructs a font metrics object for \fIfont.\fR.PPThe font must be screen-compatible, i.e. a font you use when drawing text in widgets or pixmaps. If \fIfont\fR is a printer font, you'll probably get wrong results..PPUse the QPainter::fontMetrics() to get the font metrics when painting. This is a little slower than using this constructor, but it always gives correct results..SH "QFontMetrics::QFontMetrics ( const QFontMetrics & fm )"Constructs a copy of \fIfm.\fR.SH "QFontMetrics::~QFontMetrics ()"Destroys the font metrics object..SH "int QFontMetrics::ascent () const"Returns the maximum ascent of the font..PPThe ascent is the distance from the base line to the uppermost line where pixels may be drawn..PPSee also: descent()..PPExamples:.(ldrawdemo/drawdemo.cpp scrollview/scrollview.cpp.)l.SH "QRect QFontMetrics::boundingRect ( QChar ch ) const"Returns the bounding rectangle of \fIch\fR relative to the leftmost point on the base line..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..PPNote that the rectangle usually extends both above and below the base line..PPSee also: width()..PPExamples:.(lxform/xform.cpp.)l.SH "QRect QFontMetrics::boundingRect ( const QString & str, int len = -1 ) const"Returns the bounding rectangle of the first \fIlen\fR characters of \fIstr,\fR which is the set of pixels the text would cover if drawn at (0,0)..PPIf \fIlen\fR is negative (default value), the whole string is used..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 regular characters, \fInot\fR as linebreaks..PPDue to the different actual character heights, the height of the bounding rectangle of "Yes" and "yes" may be different..PPSee also: width() and QPainter::boundingRect()..SH "QRect QFontMetrics::boundingRect ( int x, int y, int w, int h, int flgs, const QString & str, int len=-1, int tabstops=0, int * tabarray=0, char ** intern=0 ) const"Returns the bounding rectangle of the first \fIlen\fR characters of \fIstr,\fR which is the set of pixels the text would cover if drawn at (0,0)..PPIf \fIlen\fR is negative (default value), the whole string is used..PPThe \fIflags\fR argument is the bitwise OR of the following flags: .TP\fCAlignLeft\fR aligns to the left border..TP\fCAlignRight\fR aligns to the right border..TP\fCAlignHCenter\fR aligns horizontally centered..TP\fCAlignTop\fR aligns to the top border..TP\fCAlignBottom\fR aligns to the bottom border..TP\fCAlignVCenter\fR aligns vertically centered.TP\fCAlignCenter\fR (= \fCAlignHCenter\fR | AlignVCenter).TP\fCSingleLine\fR ignores newline characters in the text..TP\fCExpandTabs\fR expands tabulators..TP\fCShowPrefix\fR interprets "&x" as "x" underlined..TP\fCWordBreak\fR breaks the text to fit the rectangle..PPHorizontal alignment defaults to AlignLeft and vertical alignment defaults to AlignTop..PPIf several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined..PPThese flags are defined in the Qt namespace..PPIf \fCExpandTabs\fR is set in \fIflgs,\fR then: if \fItabarray\fR is non.zero, 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 \fIinternal\fR argument is for internal purposes..PPSee also: width() and QPainter::boundingRect()..SH "int QFontMetrics::descent () const"Returns the maximum descent of the font..PPThe descent is the distance from the base line to the lowermost line where pixels may be drawn. (Note that this is different from X, which adds 1 pixel.).PPSee also: ascent()..PPExamples:.(ldrawdemo/drawdemo.cpp.)l.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:.(lgrapher/grapher.cpp.)l.SH "bool QFontMetrics::inFont ( QChar ch ) const"Returns TRUE if \fIch\fR is a valid character in the font..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 rightward 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..PP\fISee width(QChar) for a graphical description of this metric.\fR.PPSee also: rightBearing(QChar), minLeftBearing() and width()..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:.(lscrollview/scrollview.cpp.)l.SH "int QFontMetrics::lineWidth () const"Returns the width of the underline and strike-out 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..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..PPSee also: minRightBearing() and leftBearing(char)..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..PPSee also: minLeftBearing() and rightBearing(char)..SH "QFontMetrics & QFontMetrics::operator= ( const QFontMetrics & fm )"Font metrics assignment..SH "int QFontMetrics::rightBearing ( QChar ch ) const"Returns the right bearing of character \fIch\fR in the font..PPThe right bearing is the leftward 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..PP\fISee width() for a graphical description of this metric.\fR.PPSee also: leftBearing(char), minRightBearing() and width()..SH "QSize QFontMetrics::size ( int flgs, const QString & str, int len=-1, int tabstops=0, int * tabarray=0, char ** intern=0 ) const"Returns the size in pixels of the first \fIlen\fR characters of \fIstr.\fR.PPIf \fIlen\fR is negative (default value), the whole string is used..PPThe \fIflgs\fR argument is the bitwise OR of the following flags: .TP\fCSingleLine\fR ignores newline characters in the text..TP\fCExpandTabs\fR expands tabulators..TP\fCShowPrefix\fR interprets "&x" as "x" underlined..TP\fCWordBreak\fR breaks the text to fit the rectangle..PPThese flags are defined in qwindowdefs.h..PPIf \fCExpandTabs\fR is set in \fIflgs,\fR then: if \fItabarray\fR is non.zero, 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 \fIinternal\fR argument is for internal purposes..PPSee also: boundingRect()..SH "int QFontMetrics::strikeOutPos () const"Returns the distance from the base line to where the strike-out 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 ( QChar ch ) const"Returns the logical width of a \fIch\fR in pixels. This is a distance appropriate for drawing a subsequent character after \fIch.\fR.PP<img src=bearings.png align=right> Some of the metrics are described in the image to the right. The tall dark rectangle covers the logical width() of a character. The shorter pale rectangles cover the left and right bearings of the characters. Notice that the bearings of "f" in this particular font are both negative, while the bearings of "o" are both positive..PPSee also: boundingRect()..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.PPIf \fIlen\fR is negative (default value), the whole 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. Thus, width(stra)+width(strb) is always equal to width(stra+strb). This is almost never the case with boundingRect()..PPSee also: boundingRect()..PPExamples:.(ldrawdemo/drawdemo.cpp scrollview/scrollview.cpp movies/main.cpp.)l.SH "int QFontMetrics::width ( char c ) const"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..PPProvided to aid porting from Qt 1.x..SH "SEE ALSO".BR http://www.troll.no/qt/qfontmetrics.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS.  See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?