[ Fixed ] Draft Label: Problem with Text Alignment

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

[ Fixed ] Draft Label: Problem with Text Alignment

Post by Roy_043 »

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 1987 times
Last edited by Roy_043 on Wed Dec 22, 2021 6:42 pm, edited 1 time in total.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Draft Label: Problem with Text Alignment

Post by yorik »

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
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Label: Problem with Text Alignment

Post by Roy_043 »

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.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Label: Problem with Text Alignment

Post by Roy_043 »

The bounding box problem was fixed with:
https://github.com/FreeCAD/FreeCAD/pull/5266

Texts and frames should now be properly aligned.
Post Reply