PythonQt.Qt.QRawFont
QRawFont
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
Note: QRawFont is a low level class. For most purposes QFont is a more appropriate class.
Most commonly, when presenting text in a user interface, the exact fonts used to render the characters is to some extent unknown. This can be the case for several reasons: For instance, the actual, physical fonts present on the target system could be unexpected to the developers, or the text could contain user selected styles, sizes or writing systems that are not supported by font chosen in the code.
Therefore, Qt's QFont class really represents a query for fonts. When text is interpreted, Qt will do its best to match the text to the query, but depending on the support, different fonts can be used behind the scenes.
For most use cases, this is both expected and necessary, as it minimizes the possibility of text in the user interface being undisplayable. In some cases, however, more direct control over the process might be useful. It is for these use cases the QRawFont class exists.
A QRawFont object represents a single, physical instance of a given font in a given pixel size. I.e. in the typical case it represents a set of TrueType or OpenType font tables and uses a user specified pixel size to convert metrics into logical pixel units. It can be used in combination with the QGlyphRun class to draw specific glyph indexes at specific positions, and also have accessors to some relevant data in the physical font.
QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows platforms, FreeType on Linux platforms and CoreText on macOS. For other font back-ends, the APIs will be disabled.
QRawFont can be constructed in a number of ways:
- It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The returned QGlyphs objects will contain QRawFont objects which represent the actual fonts used to render each portion of the text.
- It can be constructed by passing a QFont object to QRawFont::fromFont(). The function will return a QRawFont object representing the font that will be selected as response to the QFont query and the selected writing system.
- It can be constructed by passing a file name or QByteArray directly to the QRawFont constructor, or by calling loadFromFile() or loadFromData(). In this case, the font will not be registered in QFontDatabase, and it will not be available as part of regular font selection.
QRawFont is considered local to the thread in which it is constructed (either using a constructor, or by calling loadFromData() or loadFromFile()). The QRawFont cannot be moved to a different thread, but will have to be recreated in the thread in question.
Note: For the requirement of caching glyph indexes and font selections for static text to avoid reshaping and relayouting in the inner loop of an application, a better choice is the QStaticText class, since it optimizes the memory cost of the cache and also provides the possibility of paint engine specific caches for an additional speed-up.
Source: https://doc.qt.io/archives/qt-5.15/qrawfont.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
AntialiasingType |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
KernedAdvances |
attribute | Any |
(shared captured text) |
LayoutFlag |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
LayoutFlags |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
PixelAntialiasing |
attribute | Any |
(shared captured text) |
SeparateAdvances |
attribute | Any |
(shared captured text) |
SubPixelAntialiasing |
attribute | Any |
(shared captured text) |
UseDesignMetrics |
attribute | Any |
(shared captured text) |
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
advancesForGlyphIndexes |
function | (self, glyphIndexes: Any, advances: Any, numGlyphs: Any, layoutFlags: Any) -> tuple |
X.advancesForGlyphIndexes(glyphIndexes, advances, numGlyphs, layoutFlags) -> tuple (shared captured text) |
alphaMapForGlyph |
function | (self, glyphIndex: int, antialiasingType: Any, transform: Any) -> Any |
X.alphaMapForGlyph(glyphIndex, antialiasingType, transform) -> PythonQt.QtGui.QImage (shared captured text) |
ascent |
function | (self) -> float |
X.ascent() -> float (shared captured text) |
averageCharWidth |
function | (self) -> float |
X.averageCharWidth() -> float (shared captured text) |
boundingRect |
function | (self, glyphIndex: int) -> Any |
X.boundingRect(glyphIndex) -> PythonQt.QtCore.QRectF (shared captured text) |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
descent |
function | (self) -> float |
X.descent() -> float (shared captured text) |
familyName |
function | (self) -> str |
X.familyName() -> str (shared captured text) |
fontTable |
function | (self, tagName: str) -> Any |
X.fontTable(tagName) -> PythonQt.QtCore.QByteArray (shared captured text) |
fromFont |
function | (self, font: Any, writingSystem: Any) -> Any |
X.fromFont(font, writingSystem) -> PythonQt.QtGui.QRawFont (shared captured text) |
glyphIndexesForChars |
function | (self, chars: Any, numChars: Any, glyphIndexes: Any, numGlyphs: Any) -> bool |
X.glyphIndexesForChars(chars, numChars, glyphIndexes, numGlyphs) -> bool (shared captured text) |
glyphIndexesForString |
function | (self, text: str) -> tuple |
X.glyphIndexesForString(text) -> tuple (shared captured text) |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
hintingPreference |
function | (self) -> Any |
Returns the hinting preference used to construct this [QRawFont](https://doc.qt.io/archives/qt-5.15/qrawfont.html). (shared captured text) |
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
isValid |
function | (self) -> bool |
X.isValid() -> bool (shared captured text) |
leading |
function | (self) -> float |
X.leading() -> float (shared captured text) |
lineThickness |
function | (self) -> float |
X.lineThickness() -> float (shared captured text) |
loadFromData |
function | (self, fontData: Any, pixelSize: float, hintingPreference: Any) -> None |
X.loadFromData(fontData, pixelSize, hintingPreference) (shared captured text) |
loadFromFile |
function | (self, fileName: str, pixelSize: float, hintingPreference: Any) -> None |
X.loadFromFile(fileName, pixelSize, hintingPreference) (shared captured text) |
maxCharWidth |
function | (self) -> float |
X.maxCharWidth() -> float (shared captured text) |
operator_assign |
function | (self, other: Any) -> Any |
X.operator_assign(other) -> PythonQt.QtGui.QRawFont (shared captured text) |
pathForGlyph |
function | (self, glyphIndex: int) -> Any |
X.pathForGlyph(glyphIndex) -> PythonQt.QtGui.QPainterPath (shared captured text) |
pixelSize |
function | (self) -> float |
X.pixelSize() -> float (shared captured text) |
setPixelSize |
function | (self, pixelSize: float) -> None |
Sets the pixel size with which this font should be rendered to pixelSize. (shared captured text) |
style |
function | (self) -> Any |
Returns the style of this [QRawFont](https://doc.qt.io/archives/qt-5.15/qrawfont.html). (shared captured text) |
styleName |
function | (self) -> str |
X.styleName() -> str (shared captured text) |
supportedWritingSystems |
function | (self) -> tuple |
X.supportedWritingSystems() -> tuple (shared captured text) |
supportsCharacter |
function | (self, character: Any) -> bool |
X.supportsCharacter(character) -> bool (shared captured text) |
swap |
function | (self, other: Any) -> None |
Swaps this raw font with other. (shared captured text) |
underlinePosition |
function | (self) -> float |
X.underlinePosition() -> float (shared captured text) |
unitsPerEm |
function | (self) -> float |
X.unitsPerEm() -> float (shared captured text) |
weight |
function | (self) -> int |
X.weight() -> int (shared captured text) |
xHeight |
function | (self) -> float |
X.xHeight() -> float (shared captured text) |