Draft Label: Problem with Text Alignment

A forum dedicated to the Draft, Arch and BIM workbenches development.
User avatar
Roy_043
Posts: 1404
Joined: Thu Dec 27, 2018 12:28 pm

Draft Label: Problem with Text Alignment

Postby Roy_043 » Sat Aug 03, 2019 10:12 am

The Draft Label Text Alignment seems incorrect.
In the image both labels have the Text Alignment set to Middle.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17477 (Git)
Build type: Release
Branch: master
Hash: 8806e4490606d7a1be52c831049b17d8c8d9c320
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
DraftLabel_TextAlignment.png
DraftLabel_TextAlignment.png (4.81 KiB) Viewed 425 times
User avatar
yorik
Site Admin
Posts: 11950
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Draft Label: Problem with Text Alignment

Postby yorik » Tue Aug 13, 2019 1:00 am

Hmm apparently coin does a very bad job at guessing the size of the text bounding box. I wonder what other method we can use to guess the size of the box of text... Maybe using https://doc.qt.io/archives/qt-4.8/qfontmetrics.html
User avatar
Roy_043
Posts: 1404
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Label: Problem with Text Alignment

Postby Roy_043 » Sat Aug 17, 2019 12:03 pm

I have just discovered the Frame property. Changing this to Rectangle shows that the bounding box is indeed inaccurate (assuming the frame is drawn closely around the box). For labels created from left to right, as in the OP, the frame appears to be mirrored.

Another thing I noticed: The 'Text Size' property is in fact used as the line height.