PythonQt.QtGui.QFontMetrics · declarations 001
Back to PythonQt.QtGui.QFontMetrics
ascent
ascent() -> int
X.ascent() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::ascent() const
Returns the ascent of the font.
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 a certain character, so it is possible (though rare) that this value will be too small.
See also descent().
Upstream PySide2 reference signatures (binding differences may apply):
ascent(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#ascent
averageCharWidth
averageCharWidth() -> int
X.averageCharWidth() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::averageCharWidth() const
Returns the average width of glyphs in the font.
This function was introduced in Qt 4.2.
Upstream PySide2 reference signatures (binding differences may apply):
averageCharWidth(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#averageCharWidth
boundingRect
boundingRect(x: Any, y: Any, w: Any, h: Any, arg4: flags, text: str, tabstops: Any, tabarray: Any) -> Any
X.boundingRect(x, y, w, h, flags, text, tabstops, tabarray) -> PythonQt.QtCore.QRect
Supplemental documentation: Qt 5 reference:
QRect QFontMetrics::boundingRect(QChar ch) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the coordinate system.
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 all pixels in the bounding rectangle. For a space character the rectangle will usually be empty.
Note that the rectangle usually extends both above and below the base line.
Warning: The width of the returned rectangle is not the advance width of the character. Use boundingRect(const QString \&) or horizontalAdvance() instead.
See also horizontalAdvance().
QRect QFontMetrics::boundingRect(const QString \&text) const
Returns the bounding rectangle of the characters in the string specified by text. The bounding rectangle always covers at least the set of pixels the text would cover if drawn at (0, 0).
Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the horizontalAdvance() method returns.
If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead.
Newline characters are processed as normal characters, not as linebreaks.
The height of the bounding rectangle is at least as large as the value returned by height().
See also horizontalAdvance(), height(), QPainter::boundingRect(), and tightBoundingRect().
QRect QFontMetrics::boundingRect(const QRect \&rect, int flags, const QString \&text, int tabStops \= 0, int *tabArray \= nullptr) const
This is an overloaded function.
Returns the bounding rectangle of the characters in the string specified by text, 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 rect.
The flags argument is the bitwise OR of the following flags:
- Qt::AlignLeft aligns to the left border, except for Arabic and Hebrew where it aligns to the right.
- Qt::AlignRight aligns to the right border, except for Arabic and Hebrew where it aligns to the left.
- Qt::AlignJustify produces justified text.
- Qt::AlignHCenter aligns horizontally centered.
- Qt::AlignTop aligns to the top border.
- Qt::AlignBottom aligns to the bottom border.
- Qt::AlignVCenter aligns vertically centered
- Qt::AlignCenter (\=\=
Qt::AlignHCenter | Qt::AlignVCenter) - Qt::TextSingleLine ignores newline characters in the text.
- Qt::TextExpandTabs expands tabs (see below)
- Qt::TextShowMnemonic interprets "\&x" as x; i.e., underlined.
- Qt::TextWordWrap breaks the text to fit the rectangle.
Qt::Horizontal alignment defaults to Qt::AlignLeft and vertical alignment defaults to Qt::AlignTop.
If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.
If Qt::TextExpandTabs is set in flags, then: if tabArray is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise if tabStops is non-zero, it is used as the tab spacing (in pixels).
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 all pixels in the bounding rectangle.
Newline characters are processed as linebreaks.
Despite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same.
The bounding rectangle returned 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.
See also horizontalAdvance(), QPainter::boundingRect(), and Qt::Alignment.
QRect QFontMetrics::boundingRect(int x, int y, int width, int height, int flags, const QString \&text, int tabStops \= 0, int *tabArray \= nullptr) const
This is an overloaded function.
Returns the bounding rectangle for the given text within the rectangle specified by the x and y coordinates, width, and height.
If Qt::TextExpandTabs is set in flags and tabArray is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise, if tabStops is non-zero, it is used as the tab spacing (in pixels).
Upstream PySide2 reference signatures (binding differences may apply):
boundingRect(self, r: PySide2.QtCore.QRect, flags: int, text: str, tabstops: int=..., tabarray: typing.Optional[typing.Sequence[int]]=...) -> PySide2.QtCore.QRect
boundingRect(self, text: str) -> PySide2.QtCore.QRect
boundingRect(self, x: int, y: int, w: int, h: int, flags: int, text: str, tabstops: int=..., tabarray: typing.Optional[typing.Sequence[int]]=...) -> PySide2.QtCore.QRect
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#boundingRect
charWidth
charWidth(str: str, pos: int) -> int
X.charWidth(str, pos) -> int
Upstream PySide2 reference signatures (binding differences may apply):
charWidth(self, str: str, pos: int) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#charWidth
descent
descent() -> int
X.descent() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::descent() const
Returns the descent of the font.
The descent is the distance from the base line to the lowest point characters extend to. In practice, some font designers break this rule, e.g. to accommodate a certain character, so it is possible (though rare) that this value will be too small.
See also ascent().
Upstream PySide2 reference signatures (binding differences may apply):
descent(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#descent
elidedText
elidedText(text: str, mode: Any, width: int, arg3: flags) -> str
X.elidedText(text, mode, width, flags) -> str
Supplemental documentation: Qt 5 reference:
QString QFontMetrics::elidedText(const QString \&text, Qt::TextElideMode mode, int width, int flags \= 0) const
If the string text is wider than width, returns an elided version of the string (i.e., a string with "..." in it). Otherwise, returns the original string.
The mode parameter specifies whether the text is elided on the left (e.g., "...tech"), in the middle (e.g., "Tr...ch"), or on the right (e.g., "Trol...").
The width is specified in pixels, not characters.
The flags argument is optional and currently only supports Qt::TextShowMnemonic as value.
The elide mark follows the
layoutdirection. For
example, it will be on the right side of the text for right-to-left layouts if the
mode is Qt::ElideLeft, and on the left side of the text if the mode is
Qt::ElideRight.
This function was introduced in Qt 4.2.
Upstream PySide2 reference signatures (binding differences may apply):
elidedText(self, text: str, mode: PySide2.QtCore.Qt.TextElideMode, width: int, flags: int=...) -> str
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#elidedText
height
height() -> int
X.height() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::height() const
Returns the height of the font.
This is always equal to ascent()+descent().
See also leading() and lineSpacing().
Upstream PySide2 reference signatures (binding differences may apply):
height(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#height
inFont
inFont(arg__1: str) -> bool
X.inFont(arg__1) -> bool
Supplemental documentation: Qt 5 reference:
bool QFontMetrics::inFont(QChar ch) const
Returns true if character ch is a valid character in the font; otherwise returns
false.
Upstream PySide2 reference signatures (binding differences may apply):
inFont(self, arg__1: str) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#inFont
inFontUcs4
inFontUcs4(ucs4: int) -> bool
X.inFontUcs4(ucs4) -> bool
Supplemental documentation: Qt 5 reference:
bool QFontMetrics::inFontUcs4(uint ucs4) const
Returns true if the character ucs4 encoded in UCS-4/UTF-32 is a valid character in
the font; otherwise returns false.
Upstream PySide2 reference signatures (binding differences may apply):
inFontUcs4(self, ucs4: int) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#inFontUcs4
leading
leading() -> int
X.leading() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::leading() const
Returns the leading of the font.
This is the natural inter-line spacing.
See also height() and lineSpacing().
Upstream PySide2 reference signatures (binding differences may apply):
leading(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#leading
leftBearing
leftBearing(arg__1: str) -> int
X.leftBearing(arg__1) -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::leftBearing(QChar ch) const
Returns the left bearing of character ch in the font.
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.
See horizontalAdvance() for a graphical description of this metric.
See also rightBearing(), minLeftBearing(), and horizontalAdvance().
Upstream PySide2 reference signatures (binding differences may apply):
leftBearing(self, arg__1: str) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#leftBearing
lineSpacing
lineSpacing() -> int
X.lineSpacing() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::lineSpacing() const
Returns the distance from one base line to the next.
This value is always equal to leading()+height().
See also height() and leading().
Upstream PySide2 reference signatures (binding differences may apply):
lineSpacing(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#lineSpacing
lineWidth
lineWidth() -> int
X.lineWidth() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::lineWidth() const
Returns the width of the underline and strikeout lines, adjusted for the point size of the font.
See also underlinePos(), overlinePos(), and strikeOutPos().
Upstream PySide2 reference signatures (binding differences may apply):
lineWidth(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#lineWidth
maxWidth
maxWidth() -> int
X.maxWidth() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::maxWidth() const
Returns the width of the widest character in the font.
Upstream PySide2 reference signatures (binding differences may apply):
maxWidth(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#maxWidth
minLeftBearing
minLeftBearing() -> int
X.minLeftBearing() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::minLeftBearing() const
Returns the minimum left bearing of the font.
This is the smallest leftBearing(char) of all characters in the font.
Note that this function can be very slow if the font is large.
See also minRightBearing() and leftBearing().
Upstream PySide2 reference signatures (binding differences may apply):
minLeftBearing(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#minLeftBearing
minRightBearing
minRightBearing() -> int
X.minRightBearing() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::minRightBearing() const
Returns the minimum right bearing of the font.
This is the smallest rightBearing(char) of all characters in the font.
Note that this function can be very slow if the font is large.
See also minLeftBearing() and rightBearing().
Upstream PySide2 reference signatures (binding differences may apply):
minRightBearing(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#minRightBearing
overlinePos
overlinePos() -> int
X.overlinePos() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::overlinePos() const
Returns the distance from the base line to where an overline should be drawn.
See also underlinePos(), strikeOutPos(), and lineWidth().
Upstream PySide2 reference signatures (binding differences may apply):
overlinePos(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#overlinePos
rightBearing
rightBearing(arg__1: str) -> int
X.rightBearing(arg__1) -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::rightBearing(QChar ch) const
Returns the right bearing of character ch in the font.
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 horizontalAdvance() of the character.
See horizontalAdvance() for a graphical description of this metric.
See also leftBearing(), minRightBearing(), and horizontalAdvance().
Upstream PySide2 reference signatures (binding differences may apply):
rightBearing(self, arg__1: str) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#rightBearing
size
size(arg0: flags, str: str, tabstops: int, tabarray: Any) -> Any
X.size(flags, str, tabstops, tabarray) -> PythonQt.QtCore.QSize
Supplemental documentation: Qt 5 reference:
QSize QFontMetrics::size(int flags, const QString \&text, int tabStops \= 0, int *tabArray \= nullptr) const
Returns the size in pixels of text.
The flags argument is the bitwise OR of the following flags:
- Qt::TextSingleLine ignores newline characters.
- Qt::TextExpandTabs expands tabs (see below)
- Qt::TextShowMnemonic interprets "\&x" as x; i.e., underlined.
- Qt::TextWordWrap breaks the text to fit the rectangle.
If Qt::TextExpandTabs is set in flags, then: if tabArray is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs; otherwise if tabStops is non-zero, it is used as the tab spacing (in pixels).
Newline characters are processed as linebreaks.
Despite the different actual character heights, the heights of the bounding rectangles of "Yes" and "yes" are the same.
See also boundingRect().
Upstream PySide2 reference signatures (binding differences may apply):
size(self, flags: int, str: str, tabstops: int=..., tabarray: typing.Optional[typing.Sequence[int]]=...) -> PySide2.QtCore.QSize
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#size
strikeOutPos
strikeOutPos() -> int
X.strikeOutPos() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::strikeOutPos() const
Returns the distance from the base line to where the strikeout line should be drawn.
See also underlinePos(), overlinePos(), and lineWidth().
Upstream PySide2 reference signatures (binding differences may apply):
strikeOutPos(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#strikeOutPos
swap
swap(other: Any) -> None
X.swap(other)
Supplemental documentation: Qt 5 reference:
void QFontMetrics::swap(QFontMetrics \&other)
Swaps this font metrics instance with other. This function is very fast and never fails.
This function was introduced in Qt 5.0.
Upstream PySide2 reference signatures (binding differences may apply):
swap(self, other: PySide2.QtGui.QFontMetrics) -> None
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#swap
tightBoundingRect
tightBoundingRect(text: str) -> Any
X.tightBoundingRect(text) -> PythonQt.QtCore.QRect
Supplemental documentation: Qt 5 reference:
QRect QFontMetrics::tightBoundingRect(const QString \&text) const
Returns a tight bounding rectangle around the characters in the string specified by text. The bounding rectangle always covers at least the set of pixels the text would cover if drawn at (0, 0).
Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the horizontalAdvance() method returns.
If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead.
Newline characters are processed as normal characters, not as linebreaks.
Warning: Calling this method is very slow on Windows.
This function was introduced in Qt 4.3.
See also horizontalAdvance(), height(), and boundingRect().
Upstream PySide2 reference signatures (binding differences may apply):
tightBoundingRect(self, text: str) -> PySide2.QtCore.QRect
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#tightBoundingRect
underlinePos
underlinePos() -> int
X.underlinePos() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::underlinePos() const
Returns the distance from the base line to where an underscore should be drawn.
See also overlinePos(), strikeOutPos(), and lineWidth().
Upstream PySide2 reference signatures (binding differences may apply):
underlinePos(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#underlinePos
width
width(arg__1: str, len: int, arg2: flags) -> int
X.width(arg__1, len, flags) -> int
Upstream PySide2 reference signatures (binding differences may apply):
width(self, arg__1: str, len: int, flags: int) -> int
width(self, arg__1: str, len: int=...) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#width
xHeight
xHeight() -> int
X.xHeight() -> int
Supplemental documentation: Qt 5 reference:
int QFontMetrics::xHeight() const
Returns the 'x' height of the font. This is often but not always the same as the height of the character 'x'.
Upstream PySide2 reference signatures (binding differences may apply):
xHeight(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qfontmetrics.html#xHeight