Single path font?

987 views
Skip to first unread message

Matthew Beckler

unread,
Jan 5, 2011, 8:53:06 PM1/5/11
to eggbo...@googlegroups.com
I can't remember if we discussed this previously, but does anyone have a
good text font for use with eggbot? I'm calling it "single path font"
because if you convert regular fonts to paths, the complex outline of
each piece is converted to a path, which produces ugly results on the
eggbot.

Any ideas?

--
Matthew Beckler

signature.asc

Chuck McManis

unread,
Jan 5, 2011, 9:16:09 PM1/5/11
to eggbo...@googlegroups.com
The original Hershey Font was designed for plotters specifically. It would probably do what you want but I don't know if there is a converted one. 
--Chuck

Dan Newman

unread,
Jan 5, 2011, 11:51:21 PM1/5/11
to eggbo...@googlegroups.com
> The original Hershey Font was designed for plotters specifically. It would
> probably do what you want but I don't know if there is a converted one.

I'm not aware of a set of the Hershey fonts (simplex, or otherwise) available
for Inkscape. I suppose one could easily output them all (simplex, duplex, triplex,
Fraktur, etc.) into a single Inkscape page and you just copy, paste, and resize them
as you need them. Tedious but would work. Personally, I'd rather stick with the
inefficient plotting of our modern day fonts then go back to the Hershey fonts.

Dan

P.S. I, and probably Chuck as well, recall the days when the Hershey fonts were
the cat's whiskers.

Windell H. Oskay

unread,
Jan 6, 2011, 3:57:06 AM1/6/11
to eggbo...@googlegroups.com

>> The original Hershey Font was designed for plotters specifically. It would
>> probably do what you want but I don't know if there is a converted one.


Right. So the Hershey fonts are true vector fonts, which came into being back when pen plotters were a little more popular. Here's some additional background information, along with samples:

http://idlastro.gsfc.nasa.gov/idl_html_help/About_Hershey_Vector_Fonts.html
http://idlastro.gsfc.nasa.gov/idl_html_help/Hershey_Vector_Font_Samples.html
http://www.batbox.org/font.html


The root problem is that there is a fundamental incompatibility between these old "vector fonts" and modern "outline fonts" such as postscript and truetype. Vector fonts define the character by the stroke-- the pen line drawn around the perimeter. It is possible to define a true single-stroke vector font that works much like hand-written text-- only going over each stroke of each letter once. By contrast, outline fonts define the character by the fill-- the area encompassed by the perimeter -- so they *necessarily* form a closed shape. In other words, it's not generally possible to have a "single stroke" outline font, because there's no stroke at all-- just a filled area.


Inkscape (just like other drawing programs that use these modern outline fonts) expects every font to complete full outlines (that it can fill in) and so if you were to give it a single stroke TTF font, it will, um "helpfully" close the paths for you. The letter 'C' will render as a closed shape, for example.


Now, there *are* true single-stroke TTF fonts available, but they behave a little strangely with all those caveats. A set of fairly nice ones is available for download here, of which Machine Tool gothic is my favorite:
http://www.featurecam.com/general/support/engrave_fonts.asp

To use these fonts with Inkscape and the Eggbot, you'll need to do several things:

1) Convert to path, as per usual.
2) Set fill to 'none,' and select some visible stroke value so that you can see the vector lines. (This is in contrast to normal fonts, where you need the fill to be visible, and the stroke can be 'none.'
and
3) Individually edit the path for each character to delete the last data point, which is (I believe) automatically added by Inkscape to close the path.

Step 3 is totally impractical for one-off designs, but it's a freaking miracle time saver for mass production, if you're plotting the same thing over and over. (We use these fonts to create efficient marking paths for use with the laser engraver.)

While I haven't looked into doing so yet, it occurs to me now that we might be able to write an Inkscape extension that will automatically delete that last point, which would actually make this into a not-too-painful method.

-Windell

Matthew Beckler

unread,
Jan 6, 2011, 9:33:02 AM1/6/11
to eggbo...@googlegroups.com
Windell,

Thanks for the email. I got Machine Tool Gothic working in Inkscape. I
agree that your step 3 below can be a pain for one-offs, but it's not
too bad for mass produced designs.

Thanks again!

--
Matthew

signature.asc

Dan Newman

unread,
Jan 6, 2011, 11:15:10 AM1/6/11
to eggbo...@googlegroups.com
> 3) Individually edit the path for each character to delete the last data point, which is (I believe) automatically added by Inkscape to close the path.

In general it's more than just the last data point. Try "A" for example in the machine gothic. Issue being that some
of the paths are a single SVG path but with multiple, disjoint line segments (i.e., with non-termimal pen ups within
the path).

But, I suspect that if an extension removed the final "Z", "z", xor last data point from each continuous line segment
AND then fixed up the start of the next line segment within the path (in the case of relative path coordinates), then
everything would be okay. And such an extension might as well also set the fill to none and the stroke to black in the
parent group so as to handle that aspect as well.

Finding all the characters can be done with an assumption and xpath: assume that any group, <g>, with font info in its
style attribute is a group of font characters. Then walk all that groups child paths, <p>, and do the extension
magic.

Dan

P.S. For the letter "A" I had to change

<path
d="m 159.96205,416.50394 42.25781,-94.5 42.25782,94.5 -84.51563,0 m 15.67969,-34.52344 53.29687,0.0703 -53.29687,-0.0703"
style=""
id="path3009" />
to

<path
d="m 159.96205,416.50394 42.25781,-94.5 42.25782,94.5 m -68.83594,-34.52344 53.29687,0.0703"
style=""
id="path3009" />

John Laur

unread,
Jan 6, 2011, 12:02:46 PM1/6/11
to eggbo...@googlegroups.com
I have been working on converting hershey fonts into SVG such that they would be relatively easy to copy/paste into a line of text and then fix up with the align and distribute tools. It might be possible to make an inksape extension to automate it, but we'll have to see. I have all the glyphs from one font broken out; ill try to post my work in progress stuff tonight.

As pointed out before, the problem with pretty much all modern font formats (postscript, truetype, opentype, etc.) is that they all define glyphs based on closed paths. Depending on how the OS or rendering library handles them even if you use some of the available single-line fonts out there, it can be tedious and time consuming to make them work. For instance I was never able to get the single line truetypes working in inkscape despite trying the process windell detailed. I was using Inkscape under OS X 10.6.5 with the latest XQuartz.

Does anyone know if SVG fonts allow open paths (or other aribitrary svg) in glyph definitions. Maybe when/if Inkscape's support of SVG fonts (particularly embedded svg fonts) improves the easiest thing to do would be to convert hershey fonts directly into svg fonts?

Windell H. Oskay

unread,
Jan 6, 2011, 12:45:29 PM1/6/11
to eggbo...@googlegroups.com

On Jan 6, 2011, at 9:02 AM, John Laur wrote:

> For instance I was never able to get the single line truetypes working in inkscape despite trying the process windell detailed. I was using Inkscape under OS X 10.6.5 with the latest XQuartz.

That's my configuration as well, so the issue is probably elsewhere. Can you say in what way it wasn't working?

-Windell

Windell H. Oskay

unread,
Jan 6, 2011, 12:49:57 PM1/6/11
to eggbo...@googlegroups.com

On Jan 6, 2011, at 9:02 AM, John Laur wrote:
> As pointed out before, the problem with pretty much all modern font formats (postscript, truetype, opentype, etc.) is that they all define glyphs based on closed paths.

Too true. But... we don't actually *need* to use one of the modern font formats to solve this problem.

Here's a possible approach, thinking ahead. Suppose that we write an extension where you type a string, and the extension *draws* that text on your page for you. It would contain the definition of a character set, and output not a text object, but a grouped path, which you can move around and resize. We could base it on one of the real Hershey fonts, even. Maybe even a font-face drop-down menu. :)

Dan Newman

unread,
Jan 6, 2011, 12:55:17 PM1/6/11
to eggbo...@googlegroups.com
FWIW,

I just put the .ttf file into /Library/Fonts/ and then exited and restarted Inkscape.
Inkscape, when it detects new fonts is "slow" to startup. But, you'll see that it is
running and consuming plenty of CPU as it re-digests your various font directories.

I mention this on the offchance that you didn't get this far with the fonts.

After you get, say, machine gothic recognized by Inkscape, when you write some
letters with it, you will think that it's not working at all. Just some big,
filled, illegible shapes. It's not until you disable the fill and then enable
the stroke that you will see something resembling characters and not chunky blobs.

Dan

Dan Newman

unread,
Jan 6, 2011, 1:05:56 PM1/6/11
to eggbo...@googlegroups.com

Theory says you could put each Hershey font into a separate .py file and
have the extension import the proper .py file and draw from it. Oh, I keep
on forgetting. Computers are faster and have more memory than the PDPs and DECSYSTEMs
I used to have to do this stuff on. No need to make such optimizations these days.

But, yes this is quite doable. Any volunteers? Be sure to get the Hershey math
symbols font please.

Dan

P.S. I'm not volunteering. Last time I did this was for pre 1.0 Ghostscript. (Later
redone by Tom Wolff when the font support got revamped.)

P.P.S. I'm curious as to how well the Triplex Roman will look: I'm guessing either hideous
or somewhat nice (with a fat pen that will make the inside stroke look enough like a solid
fill).

Windell H. Oskay

unread,
Jan 6, 2011, 1:38:41 PM1/6/11
to eggbo...@googlegroups.com
> P.S. I'm not volunteering. Last time I did this was for pre 1.0
> Ghostscript. (Later
> redone by Tom Wolff when the font support got revamped.)

Still have your old code as a starting point? ;)

Seriously though, I'll look around and see if someone's already most of
the way there. It's likely that this won't be too difficult, at least for
plain text strings.

John Laur

unread,
Jan 6, 2011, 3:04:51 PM1/6/11
to eggbo...@googlegroups.com
The point at which I started was the program "HershTrans" by David Given:


It is a java program that can convert hershey fonts between various other formats including SVG. It's a bit error prone, and the output is very far away from an SVG font (it in fact produces invalid SVG -- there are non-ascii bytes in the output). Nonetheless it does work and you can with some effort get the SVG file to open and it contains single stroke paths as it should along with some paths to help with character alignment and dimensions.

I was hoping to modify hershtrans to produce real SVG typefaces that could be published as SVG and then used directly in Inkscape. Sadly support of SVG fonts in Inkscape (and any other SVG application for that matter) is pretty much nonexistent. If someone is going to take the time to write an inkscape extension to plot text, my suggestion would be to have the extension derive the glyph geometry from a real honest-to-goodness SVG font. It would be useful for plotting from other svg fonts too and maybe be a passable solution until Inkscape gets "real" svg font support.

I believe there is little use in fooling with building another parser for the original hershey fonts. As far as I know there are only a couple dozen fonts, nobody is making new ones, and they only have to be converted to SVG fonts once for everyone, ever.

Marty McGuire

unread,
Feb 6, 2011, 7:17:14 PM2/6/11
to EggBotUser
Hi All,

I was playing with these fonts and some JavaScript to read and work
with them. In the process, I've generated a set of SVGs containing all
of the glyphs of each set.

You can find them (and instructions for using them with Inkscape) on
Thingiverse:

http://www.thingiverse.com/thing:6168

Thanks,
Marty

Windell H. Oskay

unread,
Feb 6, 2011, 7:32:47 PM2/6/11
to eggbo...@googlegroups.com

On Feb 6, 2011, at 4:17 PM, Marty McGuire wrote:

> Hi All,
>
> I was playing with these fonts and some JavaScript to read and work
> with them. In the process, I've generated a set of SVGs containing all
> of the glyphs of each set.
>
> You can find them (and instructions for using them with Inkscape) on
> Thingiverse:
>
> http://www.thingiverse.com/thing:6168
>
> Thanks,
> Marty

Thank you, Marty, that's awesome!

-Windell

Firdaus Dastoor

unread,
Feb 7, 2011, 7:18:12 AM2/7/11
to eggbo...@googlegroups.com
Thank you Marty. This will help me a lot.

Phil


--
You received this message because you are subscribed to the Google Groups "EggBotUser" group.
To post to this group, send email to eggbo...@googlegroups.com.
To unsubscribe from this group, send email to eggbotuser+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/eggbotuser?hl=en.


Reply all
Reply to author
Forward
0 new messages