FontMetrics QML Type

Provides metrics for a given font. 更多...

import 语句: import QtQuick 2.2
Since: Qt 5.4

特性

方法

详细描述

FontMetrics calculates the size of characters and strings for a given font.

It provides a subset of the C++ QFontMetricsF API, with the added ability to change the font that is used for calculations via the font 特性。

FontMetrics {
    id: fontMetrics
    font.family: "Arial"
}
Rectangle {
    width: fontMetrics.height * 4
    height: fontMetrics.height * 2
}
					

另请参阅 QFontMetricsF and TextMetrics .

特性文档编制

ascent : real

This property holds the ascent of the font.

另请参阅 QFontMetricsF::ascent() , descent ,和 height .

averageCharacterWidth : real

This property holds the average width of glyphs in the font.

另请参阅 QFontMetricsF::averageCharWidth() .

descent : real

This property holds the descent of the font.

另请参阅 QFontMetricsF::descent() , ascent ,和 height .

font : font

This property holds the font used for the metrics calculations.

height : real

This property holds the height of the font.

另请参阅 QFontMetricsF::height() .

leading : real

This property holds the leading of the font.

另请参阅 QFontMetricsF::leading() .

lineSpacing : real

This property holds the distance from one base line to the next.

另请参阅 QFontMetricsF::lineSpacing() .

lineWidth : real

This property holds the width of the underline and strikeout lines, adjusted for the point size of the font.

另请参阅 QFontMetricsF::lineWidth() .

maximumCharacterWidth : real

This property holds the width of the widest character in the font.

另请参阅 QFontMetricsF::maxWidth() .

minimumLeftBearing : real

This property holds the minimum left bearing of the font.

另请参阅 QFontMetricsF::minLeftBearing() .

minimumRightBearing : real

This property holds the minimum right bearing of the font.

另请参阅 QFontMetricsF::minRightBearing() .

overlinePosition : real

This property holds the distance from the base line to where an overline should be drawn.

另请参阅 QFontMetricsF::overlinePos() , underlinePosition ,和 strikeOutPosition .

strikeOutPosition : real

This property holds the distance from the base line to where the strikeout line should be drawn.

另请参阅 QFontMetricsF::strikeOutPos() , overlinePosition ,和 underlinePosition .

underlinePosition : real

This property holds the distance from the base line to where an underscore should be drawn.

另请参阅 QFontMetricsF::underlinePos() , overlinePosition ,和 strikeOutPosition .

xHeight : real

This property holds the 'x' height of the font.

另请参阅 QFontMetricsF::xHeight() .


方法文档编制

qreal advanceWidth ( string text )

This method returns the advance in pixels of the characters in text . This is the distance from the position of the string to where the next string should be drawn.

This method is offered as an imperative alternative to the advanceWidth property of TextMetrics .

另请参阅 QFontMetricsF::horizontalAdvance() and QFontMetricsF::height() .

rect boundingRect ( string text )

This method returns the bounding rectangle of the characters in the string specified by text .

This method is offered as an imperative alternative to the boundingRect property of TextMetrics .

另请参阅 QFontMetricsF::boundingRect() and tightBoundingRect() .

string elidedText ( string text , enumeration mode , real width , int flags )

This method returns an elided version of the string (i.e., a string with "..." in it) if the string text 宽于 width . Otherwise, returns the original string.

mode argument specifies the text elide mode; that is, where the ellipsis should appear when displaying text that doesn't fit.

flags 自变量是可选的,且目前只支持 Qt::TextShowMnemonic .

This method is offered as an imperative alternative to the elidedText property of TextMetrics .

另请参阅 Qt::TextElideMode and QFontMetricsF::elidedText() .

rect tightBoundingRect ( string text )

This method returns a tight bounding rectangle around the characters in the string specified by text .

This method is offered as an imperative alternative to the tightBoundingRect property of TextMetrics .

另请参阅 QFontMetricsF::tightBoundingRect() and boundingRect() .