MAKE MORE with Inkscape – Stroke Fonts

MAKE MORE with Inkscae - Stroke Fonts

MAKE MORE with Inkscae - Stroke Fonts

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.

comparison outline vs. stroke fonts
From top to bottom: the normal rendering in TrueType, the way a laser or engraver would take using this font, the stroke font for this font – Allura (EMS Allure)
comparison outline vs. stroke fonts
These examples should help to illustrate the problem. The top path was made with a 0.1 mm tool. The bottom example shows how the font becomes blocky when a 1 mm tool is used.

Hershey Text Extension

The Hershey Font extension was developed by Windell Oskey (also known as evilmadscientist) for use with his EggBot to write on eggs.

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

the Hershey fonts which come with Inkscape
On the left: the dialog window, with the settings used to render the font table. On the right: all the fonts included with the Hershey Text Extension.
all glyphs of a stroke font rendered - glyph table
Glyph table of Hershey Script 1 stroke font, rendered with the Hershey Text extension. Choose in the Utilities tab – Generate glyph table in selected font.

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:

render a text with the Hershey Text extension

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.

Stroke Fonts Extensions - create a font design template
The dialog window for the setup of a stroke font 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.

a rendered font design template
A glyph design template

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.

an existing stroke font opened
The glyph table that gets rendered when you open a font for editing

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.

exporting the stroke font

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.

a stick font

Conclusion

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.

Fedora Project community

9 Comments

  1. JMMM

    Grandioso

  2. Peter Braet

    There is no .config/inkscape/extensions/ directory in Fedora.
    It is in /usr/share/inkscape/extensions
    where we do not have write permissions as user. Only root can do that.
    Commandline please.

    • I think in an earlier article in the series it was stated that the directory may need to be created if it doesn’t already exist.

    • It is in /usr/share/inkscape/extensions
      where we do not have write permissions as user.

      I might have an idea about what the problem is. It sounds like you are using Fedora Silverblue which is still classified as an “emerging” edition. The articles on Fedora Magazine are generally written for the Workstation edition unless otherwise stated. Things might (should) work on emerging editions, but there is no guarantee.

    • Stephen

      Hello Peter,
      In Silverblue, which I use Inkscape on, I can definitely say there is a ~/.config/inkscape/extensions directory.

      • Neil Darlow

        Is your Inkscape install a layered RPM? For a flatpak (either fedora or flathub) user-added extensions would be in:

        .var/app/org.inkscape.Inkscape/config/inkscape/extensions/

        This is in fact moot because the flatpak from the fedora repository has the Hershey Text extension installed and it works out-of-the-box. The flathub flatpak has the extension but is missing a dependency which breaks it.

    • there is and /usr/sar/inksape /extensions is for system-wide installations

  3. Can you be more specific about what doesn’t work? The editors sometimes try to test things that are written. But I admit that I haven’t verified the last two articles (I did walk through the first one and it was fine).

  4. what you want to report? Think I am well know inside the Fedora Project, I use since more then 12 years the mail address gnokii@fedoraproject.org

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions