Font trouble

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!
perot
Posts: 145
Joined: Wed Aug 30, 2017 5:40 pm

Font trouble

Post by perot »

Font files often have more than one version of the font inside. Common, for instance, is a bold version of the primary font. It seems to me FreeCAD's ShapeString cannot access those secondary fonts. If I'm wrong here, please tell me how.

So in order to utilise such a secondary font, I used Inkscape to render the text that I need, exporting the contour paths as a SVG file, and importing those into FreeCAD. When I extruded them, some letters gave invalid solids. This was the case with letters that contain a lot of arcs, rather than straight edges. Draft:Downgrading them to a wire, and then edges, allowed me to examine them in detail, and I found the source of the trouble: The contour in those cases is not properly closed. So the letter capital "C" looks like
c1a.png
c1a.png (17.68 KiB) Viewed 1367 times
but when the bottom is hugely magnified, it is this:
c2a.png
c2a.png (6.87 KiB) Viewed 1367 times
As a test, I removed the tiny edge together with one of the neighbouring edges (arc). Draft:Upgrading and extruding works and gives a valid solid now, but the letter is mutilated as the deleted arc is replaced with an automatically generated straight line, closing the wire.

How to fix this situation? The first step of course is deleting the tiny edge, but how do I close the wire manually, in a proper way? It requires modification of one of the neighbouring edges. It'd be a straightforward job if one of them were a straight line; I could just delete that one, and it'd get automatically closed in the proper way. But how do I modify arcs? The Data/View does not show the arc's parameters. Depending on the parametrisation, the solution may be to replace the arc's end-point coordinates with the coordinates of the adjacent end-point of the other arc (i.e. making the two end-points of the tiny, now deleted, edge identical). But, how to access those parameters?

Cheers Peter
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Font trouble

Post by chrisb »

perot wrote: Sat Dec 04, 2021 9:22 am How to fix this situation?
I would try to fix this at its root: Fontforge is another free program, which can edit the fonts themselves and fix them. You can probably also split the file and make the secondary font directly available to FreeCAD.
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: Font trouble

Post by Roy_043 »

perot wrote: Sat Dec 04, 2021 9:22 am Font files often have more than one version of the font inside. Common, for instance, is a bold version of the primary font. It seems to me FreeCAD's ShapeString cannot access those secondary fonts. If I'm wrong here, please tell me how.
AFAIK you are wrong. The bold version of a font is a different file. So all you need to do is select the right file.

F.e. for the Arial font I have 4 files:
arial.ttf
arialbd.ttf
arialbi.ttf
ariali.ttf


For Arial Bold you would need arialbd.ttf.
perot
Posts: 145
Joined: Wed Aug 30, 2017 5:40 pm

Re: Font trouble

Post by perot »

chrisb wrote: Sat Dec 04, 2021 9:53 am
perot wrote: Sat Dec 04, 2021 9:22 am How to fix this situation?
I would try to fix this at its root: Fontforge is another free program, which can edit the fonts themselves and fix them. You can probably also split the file and make the secondary font directly available to FreeCAD.
Ok, I'll try that. It may be beneficial in more than this one aspect. Thanks.

Nevertheless, curiosisty (or call it the drive to learn :-) ) lets me wonder about fixing the arcs. That would be a more generally applicable skill, as situations requiring that are not restricted to font work.

Cheers Peter
perot
Posts: 145
Joined: Wed Aug 30, 2017 5:40 pm

Re: Font trouble

Post by perot »

Roy_043 wrote: Sat Dec 04, 2021 10:10 am
perot wrote: Sat Dec 04, 2021 9:22 am Font files often have more than one version of the font inside. Common, for instance, is a bold version of the primary font. It seems to me FreeCAD's ShapeString cannot access those secondary fonts. If I'm wrong here, please tell me how.
AFAIK you are wrong. The bold version of a font is a different file. So all you need to do is select the right file.

F.e. for the Arial font I have 4 files:
arial.ttf
arialbd.ttf
arialbi.ttf
ariali.ttf


For Arial Bold you would need arialbd.ttf.
Wow.

So just because specifically for the Arial font my statement is not true, you figure it must be wrong in general? What aspect of the word "often" in my statement "Font files often have more than one version of the font inside." is unfamiliar to you?

I suggest you try to find the font file with which FreeCAD can use the "Gungsuh" font. If you're working with Windows, then the font is installed. But you won't be successful, because "Gungsuh" does not exist as a separate file, but is a secondary font in the font file named "batang.ttc", of which the primary font, not surprisingly, is "Batang".

Cheers Peter

PS.: In fact, "Gungsuh" is the second secondary font in the "batang.ttc" file, which comprises the fonts

Code: Select all

Batang
BatangChe
Gungsuh
GungsuhChe
"Che" is a condensed version of the Font listed before.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Font trouble

Post by chrisb »

perot wrote: Sat Dec 04, 2021 10:23 am Nevertheless, curiosisty (or call it the drive to learn :-) ) lets me wonder about fixing the arcs. That would be a more generally applicable skill, as situations requiring that are not restricted to font work.
You can edit the points in Draft, which is often convenient for such things.
You can also use Draft Draft2Sketch and edit the corresponding sketch. If possible you can remove offending stuff and add tangent constraints. Alas, this not possible in the middle of a B-spline, where you have to move the control points instead.
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: Font trouble

Post by Roy_043 »

perot wrote: Sat Dec 04, 2021 10:34 amWow.
Hmm, maybe you are being a bit too sensitive here. Note that I said 'AFAIK'.

I'll have a look at the fonts you have mentioned.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Font trouble

Post by chrisb »

Let's return to the facts. This may help clarifying: https://developer.mozilla.org/en-US/doc ... onts_Guide .
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: Font trouble

Post by Roy_043 »

Thanks Chris. I see that @perot is right: there are font files that contain multiple versions. And Draft_ShapeString indeed does not support that.
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Font trouble

Post by wandererfan »

perot wrote: Sat Dec 04, 2021 9:22 am Font files often have more than one version of the font inside. Common, for instance, is a bold version of the primary font. It seems to me FreeCAD's ShapeString cannot access those secondary fonts. If I'm wrong here, please tell me how.
ShapeString always uses the first typeface in the font file. Assuming the font license allows it, you can create separate files for each typeface using the "Generate Font" command in FontForge.

As for fixing the geometry of individual glyphs, FontForge is your friend here (as @chrisb said). You could edit the wires in FreeCAD, but it is tedious and would have to be repeated for each occurrence of the troublesome glyph.
Post Reply