Inkscape, the most used and loved tool of Fedora’s Design Team is not just a program for doing nice vector graphics. With vector graphics (in our case SVG) a lot more can be done. Many programs can import this format. Also, Inkscape can do a lot more than just graphics. The last article of this series showed how to design embroidery with Inkscape and the extension Ink/Stitch. This time, several extensions for Inkscape will be examined. All are helpful for working with so called Stroke or Hershey Fonts.
Stroke Fonts – Hershey Fonts
What are Stroke Fonts/Hershey Fonts
Inkscape version 0.91+ includes an extension called Hershey Text – Extensions > Text > Hershey Text. This extension brings a small set of Stroke Fonts or Hershey Fonts. If you try testing all of the extensions Inkscape comes with, you might get to this one and ask yourself, “What is it for? It just renders text?”
The name Hershey Text comes from Dr. Allen Vincent Hershey who did work in the 1960s at the US Naval Weapons Laboratory. He developed a set of fonts designed to be rendered on early cathode ray tube displays. Later, he did work at the US National Bureau of Standards. Marking material that is often small, he could re-use his knowledge about this kind of font.
What is different about this type of text or the font which is used to render it – TrueType/OpenType or PostScript fonts (so called outline fonts) – is how it describes the contour of the glyph. While on a cutting plotter this is what you want, you might not want this on a laser engraver, CNC engraver or pen plotter.
Hershey Text Extension
I had my first experience with this problem years back while playing with such a machine. But most people didn’t know about it back then.
These days, laser engravers, hobby CNC engravers and plotters are more common and this problem comes up much more often. As was stated earlier, this extension brings a small set of stroke fonts. You can render them all with an example text or render a glyph table of one of them with the function – Extensions > Text > Hershey Text
Custom Stroke Fonts Extensions
Installation of Custom Stroke Fonts Extensions
The installation of extensions from within Inkscape is still experimental. So it is better to do it manually. Download the extension and unpack the ZIP file into ~/.config/inkscape/extensions/
After a restart of Inkscape, the functions of the extension will be available under Extensions > Custom Stroke Fonts.
Render text objects to stroke fonts
It is also possible to render text objects with an existing stroke font. But the approach is a bit different. You need a rectangle object to serve as an area within which the text can flow.
To render text with stroke fonts execute Extensions > Custom Stroke Font > Render Text. You have to enter the text into the field Text or give an input text file.
You must create a rectangle shape on the canvas and have it selected when you execute this function. It is possible to use a TXT file as the source for the text. The need for a rectangle object to render the text makes it impossible to have curved text objects. You must use the Hershey Text extension for that.
You also can create a glyph table. To do so, just select it in the drop-down menu – Action:
Create a Font Design Template
As was previously stated, the main difference between the Hershey Font extension and the Stroke Fonts Extensions is that you can create and add your own stroke fonts. To do this, you will need a setup of orientation guidelines and maybe also source glyphs.
To setup such a glyph table, use the function Extensions > Custom Stroke Fonts > Create Font Design Template.
This will render a table with the given dimensions and number of glyphs. It is not the best solution. As an example, if you use 0 in the First Glyph field and you want thirty six glyphs, you might expect to get the numbers and all uppercase letters. But this will not work. In Unicode, there are other glyphs defined within that range. Unfortunately, you cannot directly provide a list of the glyphs you want. This is definitely a function that could use some improvement.
Some improvement is also needed on the dialog to choose the font for the source glyph. At first it seems that it expects a font-family. What is funny is that, as in a lot of cases, the font will be a script font face which often does not come as a family. Even with fonts that come as a family, the correct font isn’t used for rendering on the canvas. It isn’t even applied to the SVG source code. There is a easy work around for this. Just select all the font objects as they are on their own layer. Then you can change to it and use Ctrl + A to select all objects. Then change the font in the Text and Font dialogue (Shift + Ctrl + T) to the one you want.
Edit Stroke Fonts
It is easy to edit existing stroke fonts by importing them with the function Extensions > Custom Stroke Fonts > Edit Stroke Font… This will load a table with the existing glyphs of this font and their paths.
Now you can start editing the glyphs with the path tools and make whatever changes are necessary.
Save Stroke Font
To save the edited or created stroke font, there is the function Extensions > Custom Stroke Fonts > Generate Font Data.
This function will save a SVG file with the paths it contains to ~/.config/inkscape/extensions/strokefontdata. This will make the font available for this extensions and for Hershey Fonts as well.
Render Text with the Stroke Fonts Extensions
The rendering of text objects works a bit different than it does with the Hershey Text extension. With Hershey Text, you need only select a text object. But with the Stroke Fonts Extensions, you need another object to serve as the frame within which the text can be rendered.
More Extensions for working with Stroke Fonts
Besides the already-introduced Hershey Text and Stroke Font Extensions, there are other extensions that are helpful when working with stroke fonts.
If you have a stroke font in TTF/OTF format or you export them, FontForge will close the path. To revert this, you can use the extension – Open Closed Paths. To use this extension, type your text, then convert it to a path using the Path > Object to Path function. Ungroup it with Shift + Ctrl + G and then run the extension.
As the stroke fonts cannot be installed on systems the usual way, there is another extension which helps with converting them to SVG fonts which can then be converted to TrueType or OpenType fonts.
The need for stroke or Hershey fonts is not a common problem. But with the wider distribution of machines like pen plotters, laser engravers and others, this need is becoming more prevalent. With the extensions featured in this article, the Fedora Linux user should have no problem creating their own stroke fonts and using them on their machines. There is still room for improvement. But this will come as more users bring feature requests and use these extensions.