Height and fontPixelSize is not related in any way as far as I know.
Height is just the height of the bounding box for the text.

Also, you do get the real font.pixelSize when asking telephone. It's set to 
that in your component, but not overridden in your instantiation.

-Even

-----Original Message-----
From: Interest 
[mailto:[email protected]] On 
Behalf Of Jason H
Sent: 30. juni 2016 23:30
To: interestqt-project.org <[email protected]>
Subject: [Interest] font.pixelSize vs height?

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?
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to