QFontInfo露
- PyQt5.QtGui.QFontInfo
Description露
The QFontInfo class provides general information about fonts.
The QFontInfo class provides the same access functions as QFont, e.g. family(), pointSize(), italic(), weight(), fixedPitch(), styleHint() etc. But whilst the QFont access functions return the values that were set, a QFontInfo object returns the values that apply to the font that will actually be used to draw the text.
For example, when the program asks for a 25pt Courier font on a machine that has a non-scalable 24pt Courier font, QFont will (normally) use the 24pt Courier for rendering. In this case, pointSize() returns 25 and pointSize() returns 24.
There are three ways to create a QFontInfo object.
Calling the QFontInfo constructor with a QFont creates a font info object for a screen-compatible font, i.e. the font cannot be a printer font. If the font is changed later, the font info object is not updated.
(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.)
fontInfo() returns the font info for a widget鈥檚 font. This is equivalent to calling QFontInfo(widget->`font() <https://doc.qt.io/qt-5/stylesheet-reference.html#font>`_). If the widget鈥檚 font is changed later, the font info object is not updated.
fontInfo() returns the font info for a painter鈥檚 current font. If the painter鈥檚 font is changed later, the font info object is not updated.
See also
Methods露
- __init__(QFont)
Constructs a font info object for font.
The font must be screen-compatible, i.e. a font you use when drawing text in QWidget or QPixmap, not QPicture or QPrinter.
The font info 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鈥檚 attributes are changed later.
Use fontInfo() to get the font info when painting. This will give correct results also when painting on paint device that is not screen-compatible.
- __init__(QFontInfo)
Constructs a copy of fi.
- bold() → bool
TODO
- exactMatch() → bool
Returns
true
if the matched window system font is exactly the same as the one specified by the font; otherwise returnsfalse
.See also
- family() → str
Returns the family name of the matched window system font.
See also
- fixedPitch() → bool
Returns the fixed pitch value of the matched window system font.
See also
- italic() → bool
Returns the italic value of the matched window system font.
See also
- pixelSize() → int
Returns the pixel size of the matched window system font.
See also
- pointSize() → int
Returns the point size of the matched window system font.
See also
- pointSizeF() → float
Returns the point size of the matched window system font.
See also
- rawMode() → bool
TODO
- styleHint() → StyleHint
Returns the style of the matched window system font.
Currently only returns the style hint set in QFont.
See also
- styleName() → str
Returns the style name of the matched window system font on systems that support it.
See also
- swap(QFontInfo)
TODO
- weight() → int
Returns the weight of the matched window system font.