Skip to content

PythonQt.QtGui.QFontMetricsF · declarations 001

Back to PythonQt.QtGui.QFontMetricsF

ascent

ascent() -> float

X.ascent() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#ascent

averageCharWidth

averageCharWidth() -> float

X.averageCharWidth() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#averageCharWidth

boundingRect

boundingRect(r: Any, arg1: flags, string: str, tabstops: Any, tabarray: Any) -> Any

X.boundingRect(r, flags, string, tabstops, tabarray) -> PythonQt.QtCore.QRectF

Supplemental documentation: Qt 5 reference:

QRectF QFontMetricsF::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 height().

See also horizontalAdvance(), height(), and QPainter::boundingRect().

QRectF QFontMetricsF::boundingRect(QChar ch) const

Returns the bounding rectangle of the character ch relative to the left-most point on the base line.

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.

Note that the rectangle usually extends both above and below the base line.

See also horizontalAdvance().

QRectF QFontMetricsF::boundingRect(const QRectF \&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 given text. This is the set of pixels the text would cover if drawn when constrained to the bounding rectangle specified by rect. If rect is a reference to a nullptr object, e.g. when passing a default constructed QRectF, the bounding rectangle will not constrain itself to the size.

The flags argument is the bitwise OR of the following flags:

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.

These flags are defined in Qt::AlignmentFlag.

If Qt::TextExpandTabs is set in flags, the following behavior is used to interpret tab characters in the text:

  • If tabArray is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs in the text.
  • 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.

Newline characters are processed as line breaks.

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.

Upstream PySide2 reference signatures (binding differences may apply):

boundingRect(self, r: PySide2.QtCore.QRectF, flags: int, string: str, tabstops: int=..., tabarray: typing.Optional[typing.Sequence[int]]=...) -> PySide2.QtCore.QRectF
boundingRect(self, string: str) -> PySide2.QtCore.QRectF

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#boundingRect

descent

descent() -> float

X.descent() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::descent() const

Returns the descent of the font.

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 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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#descent

elidedText

elidedText(text: str, mode: Any, width: float, arg3: flags) -> str

X.elidedText(text, mode, width, flags) -> str

Supplemental documentation: Qt 5 reference:

QString QFontMetricsF::elidedText(const QString \&text, Qt::TextElideMode mode, qreal 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 (for example, "...tech"), in the middle (for example, "Tr...ch"), or on the right (for example, "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: float, flags: int=...) -> str

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#elidedText

height

height() -> float

X.height() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#height

inFont

inFont(arg__1: str) -> bool

X.inFont(arg__1) -> bool

Supplemental documentation: Qt 5 reference:

bool QFontMetricsF::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/qfontmetricsf.html#inFont

inFontUcs4

inFontUcs4(ucs4: int) -> bool

X.inFontUcs4(ucs4) -> bool

Supplemental documentation: Qt 5 reference:

bool QFontMetricsF::inFontUcs4(uint ch) const

Returns true if the character given by ch, 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/qfontmetricsf.html#inFontUcs4

leading

leading() -> float

X.leading() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#leading

leftBearing

leftBearing(arg__1: str) -> float

X.leftBearing(arg__1) -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#leftBearing

lineSpacing

lineSpacing() -> float

X.lineSpacing() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#lineSpacing

lineWidth

lineWidth() -> float

X.lineWidth() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#lineWidth

maxWidth

maxWidth() -> float

X.maxWidth() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::maxWidth() const

Returns the width of the widest character in the font.

Upstream PySide2 reference signatures (binding differences may apply):

maxWidth(self) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#maxWidth

minLeftBearing

minLeftBearing() -> float

X.minLeftBearing() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#minLeftBearing

minRightBearing

minRightBearing() -> float

X.minRightBearing() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#minRightBearing

overlinePos

overlinePos() -> float

X.overlinePos() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#overlinePos

rightBearing

rightBearing(arg__1: str) -> float

X.rightBearing(arg__1) -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#rightBearing

size

size(arg0: flags, str: str, tabstops: int, tabarray: Any) -> Any

X.size(flags, str, tabstops, tabarray) -> PythonQt.QtCore.QSizeF

Supplemental documentation: Qt 5 reference:

QSizeF QFontMetricsF::size(int flags, const QString \&text, int tabStops \= 0, int *tabArray \= nullptr) const

Returns the size in pixels of the characters in the given text.

The flags argument is the bitwise OR of the following flags:

These flags are defined in the Qt::TextFlag enum.

If Qt::TextExpandTabs is set in flags, the following behavior is used to interpret tab characters in the text:

  • If tabArray is non-null, it specifies a 0-terminated sequence of pixel-positions for tabs in the text.
  • If tabStops is non-zero, it is used as the tab spacing (in pixels).

Newline characters are processed as line breaks.

Note: 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.QSizeF

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#size

strikeOutPos

strikeOutPos() -> float

X.strikeOutPos() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#strikeOutPos

swap

swap(other: Any) -> None

X.swap(other)

Supplemental documentation: Qt 5 reference:

void QFontMetricsF::swap(QFontMetricsF \&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.QFontMetricsF) -> None

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#swap

tightBoundingRect

tightBoundingRect(text: str) -> Any

X.tightBoundingRect(text) -> PythonQt.QtCore.QRectF

Supplemental documentation: Qt 5 reference:

QRectF QFontMetricsF::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.QRectF

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#tightBoundingRect

underlinePos

underlinePos() -> float

X.underlinePos() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#underlinePos

width

width(arg__1: Any) -> float

X.width(arg__1) -> float

Upstream PySide2 reference signatures (binding differences may apply):

width(self, string: str) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#width

xHeight

xHeight() -> float

X.xHeight() -> float

Supplemental documentation: Qt 5 reference:

qreal QFontMetricsF::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) -> float

Source: https://doc.qt.io/archives/qt-5.15/qfontmetricsf.html#xHeight