Simple technical lettering for OpenSCAD
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Module: alpha.scad
Author: Chris Lott
Description: Implement text in OpenSCAD using the simple technical 
             lettering styles used in drafting.  This is a vector-style 
             of "font".

I'm using the following two modules:

1. arc.scad
  by Alex Franke (codecreations), March 2012
  Licenced under Creative Commons Attribution - Non-Commercial - Share Alike 3.0 
  Modified by rclott 2015-01 to extrude square or circular cross sections

2. ascii.scad
  ASCII lookup table and other utility functions
  from user MichaelAtOz 
  date 16 Jun 2013 
  on OpenSCAD github, issue #116 discussion thread:

Detailed Notes:

Technical Lettering used in Drafting
  see Wikipedia:

Historical (pre-computers) technical lettering styles can be found
in various references:

In modern era, 
  European standards specify ISO-3098
  American standards specify ANSI-Y14.5M-2009

An interesting discussion on this FreeCAD discussion forum:

from which we find the following ttf fonts, specifically designed
to follow these technical lettering drafting standards

1.  Micronus / Y14.5M-2009
2.  osifont / ISO-3098

This OpenSCAD module uses the pre-computer styles, which in turn
seem to have been the model for the ANSI standard.  Furthermore, an
approximation is made for some letters to avoid the missing ellipse
extrusion capability in OpenSCAD.

Wikipedia notes that ISO standards implemented certain features to 
improve legibility (except for the "one" glyph, I don't see these
features in the osifont ISO-look-alike font):

  (a) serifed "one"
  (b) barred "seven"
  (c) open "four", "six" and "nine"
  (d) rounded top "three"

I have implemented these, except "d" which  I don't understand.  
And furthemore, I chose to add the following for legibility reasons:

  (e) a diagonal bar through my zero glyph
  (f) a bar on the "Z"

Each letter is descibed by a combination of line and circular
segments (some letters actually require elliptical segments, 
for which I substituted ovals instead).

Each line segment is described by two points, beginning and ending,
in a vector as follows:  
  [x0,y0, x1,y1]

Each cicular segment is described by a center point, radius, 
and beginning and ending angle in a vector as follows:
  [x0,y0, rad, abeg,aend]

Each letter is described in a vector whose elements are as follows:

The diagrams available to me seemed to use the following grid.
Not sure if this is spelled out in the two standards or not, but 
it's easy enough to scale these letters to any desired size.

Uppercase letters are all constructed in a grid which is 6 units tall,
and most characters are either 5 or 6 units wide.  Lowercase letters
are typically 4 units tall, with a few letters being 6 units tall. 
Those letters with descenders extend two units below the baseline.
(per the referenced lettering charts shown above).

Stroke thickness should be 10% of character height.

I've assigned the arbitrary coordinate system to the grid:

    0 1 2 3 4 5 6 7 8 9 
  6 + + + + + + + + + +
  5 + + + + + + + + + +
  4 + + + + + + + + + +
  3 + + + + + + + + + +
  2 + + + + + + + + + +
  1 + + + + + + + + + +
  0 + + + + + + + + + +
 -1 + + + + + + + + + +
 -2 + + + + + + + + + +
    0 1 2 3 4 5 6 7 8 9 

Letters are drawn by extruded squares or circles.  It would be
straightforward to draw the with any arbitrary extruded polygon
with only minor changes to the code.

One note on the "end caps" of the lines. For circular letters,
it's easy to make all end caps a sphere.  But for rectangular 
cross section letters, a similar cap of a truncated pyramid 
doesn't look as good when line segments join.  To properly join
such line segments as a bigger headache than I wanted to endure.
I compromised by making circular segments have truncated
pyramidal endcaps, but line segments have half a cube (the line 
segment is essentially extended by half the cross section length).
This is an adequate compromise, and frankly I liked the circular 
cross section letters best, so I didn't pursue this further.