QML font size not working properly on the Simulator



  • When I use this in a Rectangle element to create a button. I get completely different results on the Simulator. The size of the letters is huge, while on Windows and in the designer, they have the same size. Isn't font.pointSize - platform independent way to set the size of a font? Am I doing something wrong or is it a bug?

    @ Text {
    text: qsTr("Hello Me!!!")
    verticalAlignment: Text.AlignVCenter
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.verticalCenter: parent.verticalCenter
    font.pointSize: 10
    }@



  • What's size of your Simulator? Note that BB10 device will have higher DPI than your PC. If your simulator is sized 100% it has different DPI than actual BB10 device and it will appear that font is bigger.

    Still I'm speculating a little bit here. I personally go with pixelSize relative to DPI and screen size.



  • bq. font.pixelSize : int
    Sets the font size in pixels.
    Using this function makes the font device dependent. Use pointSize to set the size of the font in a device independent manner.

    font.pointSize : real
    Sets the font size in points. The point size must be greater than zero.
    bq.

    I have the simulator scaled to 45-50% depending on the size of the monitor. If I create a button and I set the font size in points so that the text fits nicely in the button rectangle, the same text on the simulator is much larger and does not fit in the same rectange.

    Is that a bug or I need to use a different approach?



  • I will not reject possibility that simulator has some problems getting correct DPI while showing text when its font size is given in points. How size of your rectangle is calculated? Is it calculated in pixels or points? If in points where from have you got points?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.