Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. import QtQuick 2.11
  2. import QtQuick.Window 2.11
  3. import QtQuick.Layouts 1.3
  4. Window {
  5. visible: true
  6. width: 640
  7. height: 480
  8. title: qsTr("TestFont")
  9.  
  10. property real screenDpi: Screen.pixelDensity * 25.4
  11. Component.onCompleted: console.log(screenDpi,Screen.pixelDensity, Screen.devicePixelRatio)
  12. ColumnLayout {
  13.  
  14. Text {
  15. text: "Text as is in Qt"
  16. font.pixelSize: 100
  17. Rectangle {
  18. id: baselineRect
  19. x: 0
  20. y: parent.baselineOffset
  21. width: parent.contentWidth
  22. height: 1
  23. color: "pink"
  24. }
  25. Rectangle {
  26. x: 30
  27. anchors.bottom: baselineRect.top
  28. baselineOffset: parent.baselineOffset
  29. width: 30
  30. height: 100
  31. color: "red"
  32. }
  33. }
  34. Text {
  35. text: "Text proper size in 96 dpi"
  36. font.pixelSize: 100 * 96 / 72
  37. Rectangle {
  38. id: baselineRect2
  39. y: parent.baselineOffset
  40. width: parent.contentWidth
  41. height: 1
  42. color: "pink"
  43. }
  44. Rectangle {
  45. x: 30
  46. anchors.bottom: baselineRect2.top
  47. baselineOffset: parent.baselineOffset
  48. width: 30
  49. height: 100
  50. color: "red"
  51. }
  52. }
  53. Text {
  54. text: "Text proper size"
  55. font.pixelSize: 100 * screenDpi / 72
  56. Rectangle {
  57. id: baselineRect3
  58. y: parent.baselineOffset
  59. width: parent.contentWidth
  60. height: 1
  61. color: "pink"
  62. }
  63. Rectangle {
  64. x: 30
  65. anchors.bottom: baselineRect3.top
  66. baselineOffset: parent.baselineOffset
  67. width: 30
  68. height: 100
  69. color: "red"
  70. }
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement