[Solved] Centering Substring Text

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!
Kirasuna
Posts: 4
Joined: Tue Aug 04, 2020 2:44 am

[Solved] Centering Substring Text

Post by Kirasuna »

[Solved]

OS: Ubuntu 20.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4.
Build type: Release
Python version: 3.8.2
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.3.0
Locale: English/United States (en_US)

I made a cube in sketcher that had its corner constrained to the origin. I then made a 6 using the shapestring tool in the draft workbench and attempted to center it on the cube's face. It didn't look centered though and I put the 6's position to (0,0) and it wasn't flush against the y-axis almost like it's actual position was (1,0) or along those lines.
Attachments
d6.FCStd
(14.79 KiB) Downloaded 43 times
Screenshot from 2020-08-03 21-20-12.png
Screenshot from 2020-08-03 21-20-12.png (133.42 KiB) Viewed 1301 times
Last edited by Kirasuna on Thu Aug 06, 2020 1:30 am, edited 2 times in total.
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: Centering Substring Text

Post by chrisb »

Hi and welcome to the forum!

Please don't edit your FreeCAD infos, we forum regulars are used to the way it looks if you just paste it, and we can see immediately what we want to see.

Are you talking about a ShapeString (not substring)? Then it may depend on the font, where the letters are placed. Your file did not contain any such string so it is difficult to help.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Kirasuna
Posts: 4
Joined: Tue Aug 04, 2020 2:44 am

Re: Centering Substring Text

Post by Kirasuna »

chrisb wrote: Tue Aug 04, 2020 8:29 pm Hi and welcome to the forum!

Please don't edit your FreeCAD infos, we forum regulars are used to the way it looks if you just paste it, and we can see immediately what we want to see.

Are you talking about a ShapeString (not substring)? Then it may depend on the font, where the letters are placed. Your file did not contain any such string so it is difficult to help.
Sorry about the FreeCAD info, fixed that up. I did mean ShapeString. Also, I am not sure how to get the string to stay there but the number was flush against both edges of the bounding box so I don't think that is the problem. Is there a way I could keep the string in the file or any other info I could provide to help?
Attachments
Screenshot from 2020-08-04 18-21-32.png
Screenshot from 2020-08-04 18-21-32.png (23.74 KiB) Viewed 1286 times
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: Centering Substring Text

Post by chrisb »

Perhaps you uploaded the wrong file, but there is no shapestring at all in it. Usually the font is a problem between different systems, but if you use one of the Ubuntu system fonts we should be able to reproduce.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Centering Substring Text

Post by TheMarkster »

Without some horizontal spacing the characters would be too close together. Should it be space to the left or space to the right or space to both sides? It looks like the space is to both sides. It's interesting the bounding box doesn't show the margins.
Kirasuna
Posts: 4
Joined: Tue Aug 04, 2020 2:44 am

Re: Centering Substring Text

Post by Kirasuna »

chrisb wrote: Tue Aug 04, 2020 11:26 pm Perhaps you uploaded the wrong file, but there is no shapestring at all in it. Usually the font is a problem between different systems, but if you use one of the Ubuntu system fonts we should be able to reproduce.
I'll reupload the file with the Ubuntu font. The font I used this time was /usr/share/fonts/truetype/abyssinica/AbyssinicaSIL-Regular.ttf
Attachments
Screenshot from 2020-08-04 18-36-52.png
Screenshot from 2020-08-04 18-36-52.png (110.6 KiB) Viewed 1277 times
d6.FCStd
(18.42 KiB) Downloaded 30 times
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: Centering Substring Text

Post by chrisb »

I have moved the ShapeString into the body and attached it with mode Inertia2-3 to the face. Then I moved it by half of the BoundBox to the left and down. This works almost but not quite:
Attachments
Bildschirmfoto 2020-08-05 um 02.14.47.png
Bildschirmfoto 2020-08-05 um 02.14.47.png (88.68 KiB) Viewed 1270 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Centering Substring Text

Post by TheMarkster »

Could be there is some kind of cyclic dependency when referencing the boundbox by the object of the boundbox.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Centering Substring Text

Post by wandererfan »

chrisb wrote: Wed Aug 05, 2020 12:16 am Then I moved it by half of the BoundBox to the left and down. This works almost but not quite:
You need to also allow for "bearingX" (the empty space in the "em square" before the actual shape):
glyphMetrics.png
glyphMetrics.png (2.16 KiB) Viewed 1258 times
EDIT: this calculation is rubbish. Don't know what I was thinking. WF

Code: Select all

>>> s = App.ActiveDocument.ShapeString
>>> ss = s.Shape
>>> bearingX = ss.BoundBox.XMax - ss.BoundBox.XLength
The bearingX value is determined by the font designer, and will be different for every glyph in every font.
Last edited by wandererfan on Thu Aug 06, 2020 12:16 am, edited 1 time in total.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Centering Substring Text

Post by TheMarkster »

TheMarkster wrote: Wed Aug 05, 2020 1:08 am Could be there is some kind of cyclic dependency when referencing the boundbox by the object of the boundbox.
No, the XLength should not be affected by the positon of the object. Stay clear of using XMin or XMax, which would probably introduce a cyclic issue.
Post Reply