[net.graphics] How are hershey fonts coded?

aslam@uiucdcsp.CS.UIUC.EDU (08/18/86)

Couple of months ago, hershey fonts were posted to the net. The accompanying
documentation in hershey.doc and README
outlined what all the files were and two example programs, hershey.f77 and
hershey.c, could be to display the characters in hersh.oc1, hersh.oc2. What
I could not find was an explanation of the actual vector data. For example,
character 214 is coded as:
 
  214 12PURMRR RSMSR RRURVSVSURU

From the example program, the 12 indicates the number of strokes. Each of
the letter pair that follows 12 forms an x,y coordinate. The first character
pair however specifies the width of the character. If the first character of
a pair is a blank then the next pair specifies a move instead of a draw.

And now the unresolved questions.

1. What is the reference point for the coordinates that have been coded
using ascii characters? For example, the second pair "RM" yields ascii
integers

aslam@uiucdcsp.CS.UIUC.EDU (08/18/86)

For some odd reason my note got chopped. Hopefully this time it makes it
through intact.

Couple of months ago, hershey fonts were posted to the net.  The
accompanying documentation in hershey.doc and README outlined what all the
files were and two example programs, hershey.f77 and hershey.c, could be
usedto display the characters in hersh.oc1, hersh.oc2 etc.  What I could not
find was an explanation of the actual vector data.  For example, character
214 is coded as:
 
  214 12PURMRR RSMSR RRURVSVSURU

The 12 indicates the number of strokes.  Each of the letter pair that
follows 12 forms an x,y coordinate.  The first character pair however
specifies the width of the character.  If the first character of a pair is a
blank then the next pair specifies a move instead of a draw.

And now the unresolved questions.

1. What is the reference point for the coordinates that have been coded
using ascii characters? For example, the second pair "RM" yields ascii
integers 82 and 77. Where is the origin for this move?

2. Why is the width of the character coded using two characters? In the
example above the characters are "PU" which gives ascii decimals 80 and 85.

3. If I want to draw a character left justified at a particular coordinate,
say x1,y1, how do I generate vectors using the width and the strokes data.

4. If I want the characters to be of a specific height and width in inches,
how do I map the hershey font data into inches?

5. Has someone developed a symbol routine based on the hershey fonts that can
draw a text string? I.e.,

  subroutine symbol( x, y, font, height, text )
  real x,y, height
  integer font
  character *(*) text

I will welcome responses that shed more light on how the hershey font data is
coded and arranged and how to use it in the setting of a routine like symbol.

Sohail Aslam
Dept. of Computer Science.
University of Illinois at Urbana-Champaign

arpa		aslam@uiuc
csnet		aslam@uiuc.csnet
usenet		{ihnp4,seismo}!uiucdcs!aslam

pete@octopus.UUCP (Pete Holzmann) (08/23/86)

In article <7400003@uiucdcsp> aslam@uiucdcsp.CS.UIUC.EDU writes:
>Couple of months ago, hershey fonts were posted to the net.  The
>accompanying documentation in hershey.doc and README outlined what all the
>files were and two example programs, hershey.f77 and hershey.c, could be
>usedto display the characters in hersh.oc1, hersh.oc2 etc.  What I could not
>find was an explanation of the actual vector data.

Sorry. I had hoped the examples (which perform the decoding) would show the
way...

>For example, character
>214 is coded as:
> 
>  214 12PURMRR RSMSR RRURVSVSURU
>
>The 12 indicates the number of strokes.  Each of the letter pair that
>follows 12 forms an x,y coordinate.  The first character pair however
>specifies the width of the character.  If the first character of a pair is a
>blank then the next pair specifies a move instead of a draw.
>
>And now the unresolved questions.
>
>1. What is the reference point for the coordinates that have been coded
>using ascii characters? For example, the second pair "RM" yields ascii
>integers 82 and 77. Where is the origin for this move?

All data is based on an offset of 'R' == 0. The first point (RM in the example)
is the starting point for the first vector.

>2. Why is the width of the character coded using two characters? In the
>example above the characters are "PU" which gives ascii decimals 80 and 85.

The width is coded as <minx,maxx>, with reasonable (?) amounts of space
included for proportionally spaced output if you attach <maxx> of one glyph
to <minx> of the next. Kerning does occur. Symbols (e.g. circles, etc) have
a <minx,maxx> that hits the edge of the symbol.

>3. If I want to draw a character left justified at a particular coordinate,
>say x1,y1, how do I generate vectors using the width and the strokes data.

I believe you would have to scan the points for the actual minimum X value,
since <minx> includes a little space usually. The small amount of space would
probably be unnoticeable, however- I'd try using <minx> first.

>4. If I want the characters to be of a specific height and width in inches,
>how do I map the hershey font data into inches?

You would need to scale the font data. Note that you'll get in trouble with
most of the fonts, since they are almost all proportionally spaced, and may
not look as good when scaled horizontally to fit a fixed spacing. Vertical
scaling would be done using the font size info I included in the README.
Horizontal scaling would be done using the <minx, maxx> for each character.

>5. Has someone developed a symbol routine based on the hershey fonts that can
>draw a text string? I.e.,
>
>  subroutine symbol( x, y, font, height, text )
>  real x,y, height
>  integer font
>  character *(*) text

I thought I saw something like that posted to mod.sources a while back. 
Somebody else can answer this one, I hope!

>I will welcome responses that shed more light on how the hershey font data is
>coded and arranged and how to use it in the setting of a routine like symbol.

Hope this helped!

>Sohail Aslam
>Dept. of Computer Science.
>University of Illinois at Urbana-Champaign
>arpa		aslam@uiuc
>csnet		aslam@uiuc.csnet
>usenet		{ihnp4,seismo}!uiucdcs!aslam


-- 
  OOO   __| ___      Peter Holzmann, Octopus Enterprises
 OOOOOOO___/ _______ USPS: 19611 La Mar Court, Cupertino, CA 95014
  OOOOO \___/        UUCP: {hplabs!hpdsd,pyramid}!octopus!pete
___| \_____          Phone: 408/996-7746