Details
-
Type:
Bug
-
Status: Closed
-
Priority:
P4: Low
-
Resolution: Duplicate
-
Affects Version/s: 5.15.4, 6.2.0
-
Fix Version/s: None
-
Component/s: GUI: Font handling, Quick: Other
-
Labels:
-
Platform/s:
Description
When tried with the following code, it is expected that text width is same as TextMetrix width
Text { id: txt text: qsTr("NOT FOR PATIENT USE") height: 14 font.pixelSize: 11 font.family: "Courier" // "Arial" color: "#2B2D2E" font.letterSpacing: 0 } TextMetrics { id: textMetrics font: txt.font text: txt.text } Component.onCompleted: { console.log("textMetrics.width: ",textMetrics.width ) console.log("txt.implicitWidth: ",txt.implicitWidth ) }
The output is gives:
For "Arial" font: qml: textMetrics.width: 109 qml: txt.implicitWidth: 125 For "Courier" font: qml: textMetrics.width: 151 qml: txt.implicitWidth: 152
Attachments
Issue Links
- duplicates
-
QTBUG-85936 TextMetrics.width does not always give a correct width for the given text and is sometimes too short depending on the font used
-
- Closed
-