[SOLVED] Length of a ShapeString

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [SOLVED] Length of a ShapeString

Post by Roy_043 »

KDM wrote: Mon May 29, 2023 4:15 pm I guess mm isn't the units, but some font-specific thing?
The value is unitless (but internally that means mm). So this will work:

Code: Select all

-.Shape.BoundBox.XLength / 2 + 10
User avatar
KDM
Posts: 147
Joined: Sun Feb 20, 2022 9:30 am

Re: [SOLVED] Length of a ShapeString

Post by KDM »

Roy_043 wrote: Mon May 29, 2023 6:49 pm The value is unitless (but internally that means mm).
Damn. Of course it is, but that explains why I can't combine it with distance.
Again, thank you.
chrisb
Veteran
Posts: 53925
Joined: Tue Mar 17, 2015 9:14 am

Re: [SOLVED] Length of a ShapeString

Post by chrisb »

KDM wrote: Mon May 29, 2023 10:26 pm Of course it is, but that explains why I can't combine it with distance.
To combine unitless values with lengths you have either to add a unit, e.g. by multiplying the unitless value with "1mm" or remove it by dividing the unit value by "1mm".
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53925
Joined: Tue Mar 17, 2015 9:14 am

Re: [SOLVED] Length of a ShapeString

Post by chrisb »

Workshop_Notes wrote: Mon May 29, 2023 5:18 pm This makes it challenging to do any vertical alignment.
For the vertical alignment it would be good to have access to the baseline of the font. An option to use the baseline as zero for the y coordinate seems overkill though, because we don't see too many requests which would need it.

Would access to the baseline make a sensible feature request? How should it be accessed?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [SOLVED] Length of a ShapeString

Post by Roy_043 »

I don't understand, baseline alignment is the current standard.
Workshop_Notes
Posts: 590
Joined: Wed Sep 29, 2021 8:35 am

Re: [SOLVED] Length of a ShapeString

Post by Workshop_Notes »

Roy_043 wrote: Tue May 30, 2023 6:24 am I don't understand, baseline alignment is the current standard.
In normal typography, I think 'baseline' refers to the feint line on a piece of lined paper if you were handwriting. Some letters (those with decenders) project below the baseline. In FC, no letters project below the baseline. If you write 'yg' in a shapestring, the baseline is the lowest point of the tail of the 'y'. If you write 'ac', the baseline is the lowest point of these two letters. If you have two strings, 'yg' and 'bd', I think the boundbox height would be the same for a given font and size but it would be tricky to put them side by side and make them read nicely.

---

Not in response to your post, but more for the OP of the thread, this (wandererfan's reply) provides some insight - sorry I could not find it when replying yesterday:

viewtopic.php?style=4&t=37294
Post Reply