Reputation: 761
I'm playing with font size in Text
/TextInput
/TextField
in QML.
For Text
with font.family: "MS Shell Dlg 2"
everything works as expected.
The funny thing happens when I try to use "Courier" family (I want monospace font): not every font size is shown and for font.pointSize > ~20
displayed text stops growing. I tried to use font.pixelSize
but effect is exactly the same.
Is it normal behavior for Courier font in QML?
Below is Text
element used to test the behavior:
Text {
id: element
x: 10
y: 10
text: qsTr("FF")
font.pointSize: 40
font.family: "Courier" //if "MS Shell Dlg 2" used everything is ok
}
Edit:
Font size works fine for "Courier New" family... While my immediate problem is solved, I'd really like to understand what's happening for "Courier" family.
Edit 2:
From discussion below seems like it's problem specific to my machine as other people say it works for them...
Edit 3:
My environment: Qt 5.14.2 on Windows 10 machine. I'm using QtCreator 4.11.2 and mingw 64bit compiler.
Upvotes: 2
Views: 463
Reputation: 7170
Maybe due to some container for your Text
element?
This code is working for example:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
ApplicationWindow {
id: mainWindow
visible: true
width: 640
height: 480
Row {
id: buttonRow
spacing: 5
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
width: parent.width
Text {
id: element
x: 10
y: 10
text: qsTr("FF")
font.pointSize: 140
font.family: "Courier"
}
Button {
id: button1
text: "Click me"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
element.font.pointSize = element.font.pointSize + 10;
}
}
}
}
Upvotes: 0