[Interest] font.pixelSize vs height?

Jason H jhihn at gmx.com
Thu Jun 30 23:30:06 CEST 2016


I'm trying to use these two interchangeably, but they are not.

With Text, there is a fontSizeMode property. I use this in my own Text replacement called styled VFitText:

StyledText { // StyledText just sets the font.family and font.weight
	fontSizeMode: Text.VerticalFit
	font.pixelSize: 576
	width: contentWidth
}

The problem comes when I have to wrap text:

property int fontPixelSize: 20 

VFitText { // not wrapped
	property string number: telephone ? telephone : ''
	text: '<a href="tel:'+number+'">'+number+'</a>'
	onLinkActivated: Qt.openUrlExternally(link)
	height: fontPixelSize  // HEIGHT is fontPixelSize
	width: parent.width
}
VFitText { //wrapped, smaller than telephone?
	text: hours ? hours : ''
	font.pixelSize: fontPixelSize // I'd have thought this is the same as height?
	height: hours ? contentHeight : 0
	wrapMode: Text.WordWrap // wrapping, I can't set height here, because I need to take the next line
	width: parent.width
}

However because of the implementation of fontSizeMode, I cannot find out what is the actual size used. If I ask telephone what font.pixelSize is, it tells me 576.

How can I get the real font.pixelSize of the telephone text so that they come out the same?



More information about the Interest mailing list