forked from qt-creator/qt-creator
Utils: Introduce StyleHelper::uiFontLineHeight
The "Text tokens" which are defined in Figma have an additional line height value. This change adds a getter function for the line heights. Change-Id: I9513ac2f689292baf6e2c0a52fca8a1ec7f14dc1 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -1002,6 +1002,14 @@ QFont StyleHelper::uiFont(UiElement element)
|
||||
return font;
|
||||
}
|
||||
|
||||
int StyleHelper::uiFontLineHeight(UiElement element)
|
||||
{
|
||||
const UiFontMetrics &metrics = uiFontMetrics(element);
|
||||
const qreal lineHeightToPixelSizeRatio = qreal(metrics.lineHeight) / metrics.pixelSize;
|
||||
const QFontInfo fontInfo(uiFont(element));
|
||||
return qCeil(fontInfo.pixelSize() * lineHeightToPixelSizeRatio);
|
||||
}
|
||||
|
||||
QString StyleHelper::fontToCssProperties(const QFont &font)
|
||||
{
|
||||
const QString fontSize = font.pixelSize() != -1 ? QString::number(font.pixelSize()) + "px"
|
||||
|
||||
Reference in New Issue
Block a user