Homage Tek CC: Subscripts & Superscripts

The GCMC typeset() function converts UTF-8 text into a vector list, with Hershey vector fonts sufficing for most CNC projects. The fonts date back to the late 1960s and lack niceties such as superscripts, so the Homage Tektronix Circuit Computer scale legends have a simpler powers-of-ten notation:

Tek CC - Pilot V5 - plain paper - red blue
Tek CC – Pilot V5 – plain paper – red blue

Techies understand upward-pointing carets, but … ick.

After thinking it over, poking around in the GCMC source code, and sketching alternatives, I ruled out:

  • Adding superscript glyphs to the font tables
  • Writing a text parser with various formatting commands
  • Doing anything smart

Because I don’t need very many superscripts, a trivial approach seemed feasible. Start by defining the size & position of the superscript characters:

SuperScale = 0.75;                                       // superscript text size ratio
SuperOffset = [0mm,0.75 * LegendTextSize.y];            //  ... baseline offset

Half-size characters came out barely readable with 0.5 mm Pilot pens:

Tek CC - Superscript test - 0.5x
Tek CC – Superscript test – 0.5x

They’re legible and might be OK with a diamond drag point.

They work better at 3/4 scale:

Tek CC - Superscript test - 0.75x
Tek CC – Superscript test – 0.75x

Because superscripts only occur at the end of the scale legends, a truly nasty hack suffices:

function ArcLegendSuper(Text,Super,Radius,Angle,Orient) {

  local tp = scale(typeset(Text,TextFont),LegendTextSize);

  tp += scale(typeset(Super,TextFont),LegendTextSize * SuperScale) + SuperOffset + [tp[-1].x,0mm];

  local tpa = ArcText(tp,[0mm,0mm],Radius,Angle,TEXT_CENTERED,Orient);


The SuperScale constant shrinks the superscript vectorlist, SuperOffset shifts it upward, and adding [tp[-1].x,0mm] glues it to the end of the normal-size vectorlist.

Yup, that nasty.

Creating the legends goes about like you’d expect:

  ArcLegendSuper("pF - picofarad  x10","-12",r,a,INWARD);

Presenting “numeric” superscripts as text keeps the option open for putting non-numeric stuff up there, which seemed easier than guaranteeing YAGNI.

A similar hack works for subscripts:

Tek CC - Subscript test - 0.75x
Tek CC – Subscript test – 0.75x

With even more brutal code:

  Sub_C = scale(typeset("C",TextFont),LegendTextSize * SubScale) + SubOffset;

<<< snippage >>>

    tp = scale(typeset("←----- τ",TextFont),LegendTextSize);
    tp += Sub_C + [tp[-1].x,0mm];
    tp += scale(typeset(" Scale -----→",TextFont),LegendTextSize) + [tp[-1].x,0mm];

The hackage satisfied the Pareto Principle, so I’ll declare victory and move on.

2 thoughts on “Homage Tek CC: Subscripts & Superscripts

  1. The original Hershey font distribution does include some fonts sized for superscripts/subscripts, but most packages only include a subset of the font data as represented in the 1980s usenet distribution. From memory, I don’t think any of the simplex fonts have the small design sizes. Allen V. Hershey was attempting to create an entire phototypesetting system at Dahlgren, and so focused on the duplex/triplex fonts that looked better on the film recorder.

    (Yes, I’ve attempted to create a grand unified all-Unicode Hershey distribution in the past. Probably too much work for one person.)

    1. GCMC includes a very restricted subset of the Hershey font universe (for well and good reason!) and some quasi-diligent searching didn’t unearth anything more useful. If I found a suitable font, then I’d vanish in the rabbit hole of converting it into a format useful with GCMC and recompiling GCMC around it.

      Probably better to avoid temptation.

Comments are closed.