Back in late 2016, when writing the first implementation of the canvas (still in C, this was before the project transitioned to C++), there was the need for text rendering. The easiest way to render text in a vector-based application is to use a vector font where each glyph is made up of straight line segments. Opposed to proper OpenType/TrueType fonts, these have the advantage that they’re easy to scale and are guaranteed to scale as intended, as I’ve observed that at least two schematic editors using TrueType fonts failing to scale text proportionally to the rest of the schematic resulting in text overlapping other content depending on the zoom level.

After some searching around for a suitable vector font, I stumbled upon the Hershey fonts. Apart from looking pretty, they support quite a wide range of non-ASCII characters, unfortunately no German umlauts though. The glyph data is available in a rather strange format that encodes coordinates in the ASCII value of characters relative to the character R.

Since I didn’t want to reinvent the wheel as that’d also involve manually mapping ASCII values to glpyh indices, I’ve had a look for implementations that’d be easy enough to adapt for my needs and finally found the text rendering code from OpenCV to be the best fit. As of today, the text rendering code in Horizon EDA has very little resemblance with the code from OpenCV apart from the ASCII-to-glyph mapping tables.

There are still quite a few Unicode codepoints that have a corresponding glpyh in the Hershey fonts, but haven’t been mapped yet. The PDF linked in this post gives a great overview of what’s available in the font.

Only later I discovered that the Hershey Fonts are widely used among other EDA software as well, including but not limited to (Add ® and ™ as needed)

  • Cadence Virtuoso
  • Mentor Graphics Expedition PCB
  • Mentor Graphics DxDesigner
  • Keysight ADS Layout
  • P-CAD

One of the easiest way to spot the Hershey fonts is the glyph for 1 as the upper-left part is distinctively shaped (bent, not a straight line):

Also, the availability of odd script, cursive and gothic variants is a strong indicator for the usage of Hershey fonts.

Now that you know how to spot the Hershey fonts, open a pull request if you’ve found other CAD software using them as well.