QRawFont Class Reference

[QtGui module]

该QRawFont类提供了访问字体的单个物理实例。More…

Types

  • enum AntialiasingType { PixelAntialiasing, SubPixelAntialiasing }

Methods

  • __init__ (self)
  • __init__ (self, QString fileName, float pixelSize, QFont.HintingPreference hintingPreference = QFont.PreferDefaultHinting)
  • __init__ (self, QByteArray fontData, float pixelSize, QFont.HintingPreference hintingPreference = QFont.PreferDefaultHinting)
  • __init__ (self, QRawFont other)
  • list-of-QPointF advancesForGlyphIndexes (self, list-of-int glyphIndexes)
  • QImage alphaMapForGlyph (self, int glyphIndex, AntialiasingType antialiasingType = QRawFont.SubPixelAntialiasing, QTransform transform = QTransform())
  • float ascent (self)
  • float averageCharWidth (self)
  • float descent (self)
  • QString familyName (self)
  • QByteArray fontTable (self, str tagName)
  • list-of-int glyphIndexesForString (self, QString text)
  • QFont.HintingPreference hintingPreference (self)
  • bool isValid (self)
  • float leading (self)
  • loadFromData (self, QByteArray fontData, float pixelSize, QFont.HintingPreference hintingPreference)
  • loadFromFile (self, QString fileName, float pixelSize, QFont.HintingPreference hintingPreference)
  • float maxCharWidth (self)
  • QPainterPath pathForGlyph (self, int glyphIndex)
  • float pixelSize (self)
  • setPixelSize (self, float pixelSize)
  • QFont.Style style (self)
  • QString styleName (self)
  • list-of-QFontDatabase.WritingSystem supportedWritingSystems (self)
  • bool supportsCharacter (self, int ucs4)
  • bool supportsCharacter (self, QChar character)
  • float unitsPerEm (self)
  • int weight (self)
  • float xHeight (self)

Static Methods

  • QRawFont fromFont (QFont font, QFontDatabase.WritingSystem writingSystem = QFontDatabase.Any)

Special Methods

  • bool __eq__ (self, QRawFont other)
  • bool __ne__ (self, QRawFont other)

Detailed Description

该QRawFont类提供了访问字体的单个物理实例。

Note:QRawFont是一个低级别的类。对于大多数用途QFont是一个比较合适的类。

最常见的是,在用户界面中显示文本时,确切的字体用于呈现字符在某种程度上是未知的。这可能是有几个原因的情况:例如,在实际的物理存在于目标系统上的字体可能会不期而至的开发商,或者文本可以包含用户选择的样式,尺寸或书写系统不支持所选择的字体的代码。

因此, Qt的QFont类真正代表字体的查询。当文本被解释, Qt会尽力的文字查询匹配,但根据的支持,不同的字体可用于在幕后。

对于大多数用例来说,这既是预期的和必要的,因为它最大限度地减少文本的用户界面是不可显示的可能性。在某些情况下,但是,更直接地控制这个过程可能是有用的。正是由于这些用例的QRawFont类存在。

一个QRawFont对象代表一个给定的字体在一个给定的像素大小单个物理实例。即在典型的情况下,它代表一组TrueType或OpenType字体表,并使用用户指定的像素大小来度量转换为逻辑像素单位。它可与组合使用QGlyphRun类绘制特定的字形索引在特定位置,也有访问到物理字体的一些相关数据。

QRawFont只提供了主要的字体技术支持: GDI和DirectWrite在Windows平台上,FreeTypeSymbian和Linux平台和CoreText在Mac OS X。对于其他字体后端上,这些API将被禁用。

QRawFont可以以多种方式进行构造:

  • 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被认为是本地在其构造(或者使用构造函数的线程,或致电loadFromData()或loadFromFile())。该QRawFont不能移动到一个不同的线程,但会在有问题的线程被创建。

Note:对于缓存字形索引和字体选项的静态文本,以避免重塑和relayouting在应用程序的内部循环的要求,更好的选择是QStaticText类,因为它优化高速缓存的存储器成本并且还提供了额外的加速绘图引擎的特定高速缓存的可能性。


Type Documentation

  1. QRawFont.AntialiasingType

这个枚举变量代表了不同方式的字形可以在函数被光栅化alphaMapForGlyph( ) 。

Constant Value Description
QRawFont.PixelAntialiasing 0 通过测量全像素形状的复盖范围将栅格化。返回的图像中包含的每个像素的基础上,字形形状的复盖范围的alpha值。
QRawFont.SubPixelAntialiasing 1 通过测量各子像素的显示,对于每个各像素的红色,绿色和蓝色分量的返回一个单独的α值将栅格化。

Method Documentation

  1. QRawFont.__init__ (self)

构造一个无效的QRawFont

  1. QRawFont.__init__ (self, QString fileName, float pixelSize, QFont.HintingPreference hintingPreference = QFont.PreferDefaultHinting)

构造一个QRawFont表示包含由所引用的文件中的字体fileName对于通过给定的大小(以像素为单位)pixelSize,并使用所指定的提示的优先级hintingPreference

Note:引用的文件必须包含一个TrueType或OpenType字体。

  1. QRawFont.__init__ (self, QByteArray fontData, float pixelSize, QFont.HintingPreference hintingPreference = QFont.PreferDefaultHinting)

构造一个QRawFont表示包含在所提供的字体fontData对于通过给定的大小(以像素为单位)pixelSize,并使用所指定的提示的优先级hintingPreference

Note:该数据必须包含TrueType或OpenType字体。

  1. QRawFont.__init__ (self, QRawFont other)

创建QRawFont这是一个拷贝other

  1. list-of-QPointF QRawFont.advancesForGlyphIndexes (self, list-of-int glyphIndexes)

返回QRawFont的前进对每个glyphIndexes以像素为单位。该贷款给从给定字形的位置到下一个字形应绘制,使其看起来好像两个字形unspaced的距离。

See also QTextLine.horizontalAdvance()和QFontMetricsF.width( ) 。

  1. QImage QRawFont.alphaMapForGlyph (self, int glyphIndex, AntialiasingType antialiasingType = QRawFont.SubPixelAntialiasing, QTransform transform = QTransform())

该函数返回字形的光栅化图像在给定的glyphIndex在底层的字体,用transform规定。如果QRawFont是无效的,该函数将返回一个无效QImage

If antialiasingType被设置为QRawFont.SubPixelAntialiasing,然后将生成的图像将在QImage.Format_RGB32和每个像素的RGB值,将表示在该字形的光栅化的像素的子像素的不透明度。否则,图像将在格式QImage.Format_Indexed8和每个像素将包含像素的光栅化的不透明度。

See also pathForGlyph()和QPainter.drawGlyphRun( ) 。

  1. float QRawFont.ascent (self)

返回此东昇QRawFont以像素为单位。

See also QFontMetricsF.ascent( ) 。

  1. float QRawFont.averageCharWidth (self)

返回此字符的平均宽度QRawFont以像素为单位。

See also QFontMetricsF.averageCharWidth( ) 。

  1. float QRawFont.descent (self)

返回此下降QRawFont以像素为单位。

See also QFontMetricsF.descent( ) 。

  1. QString QRawFont.familyName (self)

返回此姓氏QRawFont

  1. QByteArray QRawFont.fontTable (self, str tagName)

[

检索评为SFNT表tagName从底层的物理字体,或者一个空字节数组,如果没有这样的表被发现。返回的字体表中的字节顺序是大端,像SFNT格式指定。该tagName必须为四个字符,并应在当前平台的默认字节顺序进行格式化。

]($docs-qbytearray.html)

  1. QRawFont QRawFont.fromFont (QFont font, QFontDatabase.WritingSystem writingSystem = QFontDatabase.Any)

[

取基于物理表示font查询。返回的物理字体是由Qt的首选,以在选定的显示文本的字体writingSystem

  1. list-of-int QRawFont.glyphIndexesForString (self, QString text)

unicode的点串由下式给出转换text使用CMAP表的基本字体到字形索引,并返回包含结果的载体。

]($docs-qrawfont.html)

需要注意的是,在存在于该字体的其他表影响文本的成形的情况下,返回的字形索引将不正确地表示该文本的渲染。为了得到正确的形文字,可以使用QTextLayout布置和形状的文本,然后调用QTextLayout.glyphs ( )来获取一套字形索引列表和QRawFont对。

See also advancesForGlyphIndexes( )glyphIndexesForChars( )QGlyphRunQTextLayout.glyphRuns()和QTextFragment.glyphRuns( ) 。

  1. QFont.HintingPreference QRawFont.hintingPreference (self)

返回用于构造这个暗示偏好QRawFont

See also QFont.hintingPreference( ) 。

  1. bool QRawFont.isValid (self)

返回True如果QRawFont是有效的,否则为False。

  1. float QRawFont.leading (self)

返回此领先QRawFont以像素为单位。

See also QFontMetricsF.leading( ) 。

  1. QRawFont.loadFromData (self, QByteArray fontData, float pixelSize, QFont.HintingPreference hintingPreference)

替换当前QRawFont与包含在所提供的字体fontData对于通过给定的大小(以像素为单位)pixelSize,并使用所指定的提示的优先级hintingPreference

fontData必须包含TrueType或OpenType字体。

See also loadFromFile( ) 。

  1. QRawFont.loadFromFile (self, QString fileName, float pixelSize, QFont.HintingPreference hintingPreference)

替换当前QRawFont由所引用的文件中的内容fileName对于通过给定的大小(以像素为单位)pixelSize,并使用所指定的提示的优先级hintingPreference

该文件必须引用一个TrueType或OpenType字体。

See also loadFromData( ) 。

  1. float QRawFont.maxCharWidth (self)

返回最宽的字符的字体的宽度。

See also QFontMetricsF.maxWidth( ) 。

  1. QPainterPath QRawFont.pathForGlyph (self, int glyphIndex)

这个函数返回该字形的形状在给定的glyphIndex在底层的字体,如果QRawFont是有效的。否则,它返回一个空QPainterPath

返回的字形将始终unhinted 。

See also alphaMapForGlyph()和QPainterPath.addText( ) 。

  1. float QRawFont.pixelSize (self)

返回此像素大小设置QRawFont。像素大小会影响字形光栅,通过回字形的大小pathForGlyph() ,并用于内部度量转换设计单位逻辑像素单位。

See also setPixelSize( ) 。

  1. QRawFont.setPixelSize (self, float pixelSize)

设置像素大小与该字体应该被渲染到pixelSize

See also pixelSize( ) 。

  1. QFont.Style QRawFont.style (self)

返回此风格QRawFont

See also QFont.style( ) 。

  1. QString QRawFont.styleName (self)

返回此样式名QRawFont

See also QFont.styleName( ) 。

  1. list-of-QFontDatabase.WritingSystem QRawFont.supportedWritingSystems (self)

返回根据设计师对字体支持的书写系统列表中的字体文件中提供的信息。请注意,这并不能保证在字体特定的Unicode点支撑。您可以使用supportsCharacter( )来检查一个单一的,特定的字符支持。

Note:该列表是基于字体的OS / 2表设置,需要这样一个表存在于底层的字体文件Unicode范围和代码页范围内确定。

See also supportsCharacter( ) 。

  1. bool QRawFont.supportsCharacter (self, int ucs4)

如果字体有对应于给定的字形,则返回Truecharacter

See also supportedWritingSystems( ) 。

  1. bool QRawFont.supportsCharacter (self, QChar character)

这是一个重载函数。

如果字体有对应于UCS- 4编码的字符的字形,则返回Trueucs4

See also supportedWritingSystems( ) 。

  1. float QRawFont.unitsPerEm (self)

返回设计单位的数量界定em方形这个的宽度和高度QRawFont。此值与像素尺寸转换设计度量时,以像素单位使用的,作为内部度量在设计单位指定与像素大小给出1烯的大小(像素)。

See also pixelSize()和setPixelSize( ) 。

  1. int QRawFont.weight (self)

返回此重量QRawFont

See also QFont.weight( ) 。

  1. float QRawFont.xHeight (self)

返回此的xHeightQRawFont以像素为单位。

See also QFontMetricsF.xHeight( ) 。

  1. bool QRawFont.__eq__ (self, QRawFont other)
  1. bool QRawFont.__ne__ (self, QRawFont other)