Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.11
- import QtQuick.Window 2.11
- import QtQuick.Layouts 1.3
- Window {
- visible: true
- width: 640
- height: 480
- title: qsTr("TestFont")
- property real screenDpi: Screen.pixelDensity * 25.4
- Component.onCompleted: console.log(screenDpi,Screen.pixelDensity, Screen.devicePixelRatio)
- ColumnLayout {
- Text {
- text: "Text as is in Qt"
- font.pixelSize: 100
- Rectangle {
- id: baselineRect
- x: 0
- y: parent.baselineOffset
- width: parent.contentWidth
- height: 1
- color: "pink"
- }
- Rectangle {
- x: 30
- anchors.bottom: baselineRect.top
- baselineOffset: parent.baselineOffset
- width: 30
- height: 100
- color: "red"
- }
- }
- Text {
- text: "Text proper size in 96 dpi"
- font.pixelSize: 100 * 96 / 72
- Rectangle {
- id: baselineRect2
- y: parent.baselineOffset
- width: parent.contentWidth
- height: 1
- color: "pink"
- }
- Rectangle {
- x: 30
- anchors.bottom: baselineRect2.top
- baselineOffset: parent.baselineOffset
- width: 30
- height: 100
- color: "red"
- }
- }
- Text {
- text: "Text proper size"
- font.pixelSize: 100 * screenDpi / 72
- Rectangle {
- id: baselineRect3
- y: parent.baselineOffset
- width: parent.contentWidth
- height: 1
- color: "pink"
- }
- Rectangle {
- x: 30
- anchors.bottom: baselineRect3.top
- baselineOffset: parent.baselineOffset
- width: 30
- height: 100
- color: "red"
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement