Konubinix' opinionated web of thoughts

Trying to 3D Print a Text With a Cursive Font

Fleeting

tag: learning 3D printing

I wanted to print some text using the belleallure font, using cadquery

first, installing the font

According to the documentation of fonts-conf, I can find the directories scanned for font in the <dir> element of /etc/fonts/fonts.conf.

grep '<dir' /etc/fonts/fonts.conf
<dir>/usr/share/fonts</dir>
<dir>/usr/local/share/fonts</dir>
<dir prefix="xdg">fonts</dir>
<dir>~/.fonts</dir>

If ‘prefix’ is set to “xdg”, the value in the XDG_DATA_HOME environment variable will be added as the path prefix.

— doc of fonts-conf

So I can put my fonts in $XDG_DATA_HOME/fonts. I also found out that any directory of $XDG_DATA_DIRS are scanned as well.

fc-cache -f -v|gi belleallur
/home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024
/home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024: caching, new cache contents: 11 fonts, 0 dirs
/home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024: skipping, looped directory detected

That’s good. Now, let’s try in cadquery.

then, generate the stl

Let’s find out the real name of the font I want to use

First, let’s find the otf file.

fc-list|gi bellealluregs
/home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024/BelleAllureGS-Gros.otf: Belle Allure GS:style=Gros,Bold
/home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024/BelleAllureGS-Fin.otf: Belle Allure GS:style=Fin,Regular

Then, let’s extract some information.

otfinfo -i /home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024/BelleAllureGS-Gros.otf
Family:              BelleAllureGS
Subfamily:           Bold
Full name:           Belle Allure GS Gros
PostScript name:     BelleAllureGS-Gros
Preferred family:    Belle Allure GS
Preferred subfamily: Gros
Mac font menu name:  Belle Allure GS Gros
Version:             Version 21/02/2024
Unique ID:           JBFoundry : Belle Allure GS Gros : 21-2-2024
Copyright:           JBFoundry
jbfoundry@orange.fr
Vendor ID:           Jean
Permissions:         Editable

We can check that the font is correctly matched with fc-match

fc-match "Belle Allure GS"
BelleAllureGS-Fin.otf: "Belle Allure GS" "Fin"

The full name is “Belle Allure GS Gros”, so let’s use it.

import cadquery as cq
cq.exporters.export(cq.Workplane("XY").text(text, fontsize=1, distance=1, font="Belle Allure GS Gros"), out)
return out

()

how to make the letters stick togetherĀ ?

Here is a screenshot taken using libreoffice

There is a continuity in the word. This it done thanks to the Contextual Alternates feature of the font.

This feature indicates that the font has several glyphs for the same character and is able to chose the most appropriate (the alternatives) depending on the surrounding letters (the context).

otfinfo -f /home/sam/Prog/Devel/share/fonts/BelleAllure-21-02-2024/BelleAllureGS-Gros.otf
calt	Contextual Alternates
cv00	<unknown feature>
cv01	Character Variants 1
cv02	Character Variants 2
cv03	Character Variants 3
cv05	Character Variants 5
cv06	Character Variants 6
cv07	<unknown feature>
cv08	<unknown feature>
cv10	<unknown feature>
cv99	<unknown feature>
kern	Kerning
liga	Standard Ligatures

Unfortunately, it seems that it is the duty of the application using the font to deal with this feature.

So I have to do this manually I guess

trying with openscad

$fn = 40;

linear_extrude(1)
text("scrollbar", font = "Belle Allure GS");

()

That’s greatĀ !