我一直在网上寻找解决方案,但没有找到我能力范围内的解决方案。您将如何转换这些 Hershey Font .jhf 文件 emergent.unpythonic.net/software/hershey使用 python 或 javascript 转换为 JSON。创建类似的东西:
[
{
asciival:26,
points:[[5,-5],[4,7,8],[6,8,7]]
},
{
asciival:27,
points:[[5,-3],[4,7,33],[6,32,7]]
},
(…)
]
我知道有一个question here但这还不足以让我理解这个系统。
编辑1
我已经找到了描述paulbourke.net/dataformats/hershey/肖恩在评论中指出。
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'.>
我试图理解这一点,但这些值从哪里来?
例如为什么UM是(3,-5)?
编辑2
我找到了this java class
最佳答案
坐标是连续的字符对。要将它们转换为数字,您需要从每个字符中减去字符“R”= 82 的 ascii 等效值。在您的示例中,“UM”翻译为 (3,-5),因为 U 是 ascii 代码 85。减去 82 (='R') 得到 3。M 是 ascii 代码 77,减去 82 得到 -5。
关于javascript - 使用 python 或 javascript 将 Hershey 字体 .jhf 解析为 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14041784/