I ve been searching the web for a solution but I found nothing that is within my skills. How would you transform these Hershey Font .jhf files emergent.unpythonic.net/software/hershey to JSON using python or javascript. Creating something like:
[
{
asciival:26,
points:[[5,-5],[4,7,8],[6,8,7]]
},
{
asciival:27,
points:[[5,-3],[4,7,33],[6,32,7]]
},
(…)
]
I know there is a question here but this is not enough for me to understand the system.
Edit1
I already found the descriptions paulbourke.net/dataformats/hershey/ sean pointed out in the comments.
As an example consider the 8th symbol
8 9MWOMOV RUMUV ROQUQ
It has 9 coordinate pairs (this includes the left and right position).
The left position is ‘M’ – ‘R’ = -5
The right position is ‘W’ – ‘R’ = 5
The first coordinate is "OM" = (-3,-5)
The second coordinate is "OV" = (-3,4)
Raise the pen " R"
Move to "UM" = (3,-5)
Draw to "UV" = (3,4)
Raise the pen " R"
Move to "OQ" = (-3,-1)
Draw to "UQ" = (3,-1)
Drawing this out on a piece of paper will reveal it represents an ‘H’.>
I tried to make sense out of this, but where do the values come from?
For example why is UM (3,-5)?
Edit2
I found this java class
The coordinates are consecutive pairs of characters. To translate them into numbers you subtract the ascii equivalent of the character ‘R’ = 82 from each character. In your example, “UM” translates to (3,-5) because U is ascii code 85. Subtract 82 (=’R’) to get 3. M is ascii code 77, subtract 82 to get -5.