问题
Hershey is a text-based vectorial font format defined here: http://paulbourke.net/dataformats/hershey/
The structure is bascially as follows: each character consists of a number 1->4000 (not all used) in column 0:4, the number of vertices in columns 5:7, the left hand position in column 8, the right hand position in column 9, and finally the vertices in single character pairs. All coordinates are given relative to the ascii value of 'R'. If the coordinate value is " R" that indicates a pen up operation.
I don't understand how to parse this format. For example for the character '3':
3 11MXVNTMRMPNOPOSPURVTVVU
the number of vertices is 11. What are those 11 vertices ? I would say:
MX VN TM R(pen up) MP NO PO SP UR(a 'R' here?) VT VV U(last char missing?)
but it is wrong (last coordinate is missing)
回答1:
You've got it wrong. "R" is not a "pen up" — " R" is "pen up" (space + R). The vertices are:
MX VN TM RM PN OP OS PU RV TV VU
"R" is not special, it's just the zero of the coordinate system, so "RM" is [0; -5].
回答2:
Aye - and the number of vertices is not quite a vertices count - but a count of the number of pairs to follow; including the initial left/right and the ' R' move flag. See the function parse:()path in https://github.com/dirkx/HersheyEngravingFontsForCocoaAndiPhone for an example.
来源:https://stackoverflow.com/questions/8042840/parsing-the-hershey-font-format