使用python或javascrip将Hershey-font.jhf解析为json

2024-09-30 16:23:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在网上寻找解决办法,但我没有发现任何在我能力范围内的东西。如何使用python或javascript将这些Hershey-Font.jhf文件emergent.unpythonic.net/software/hershey转换为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

我已经找到了肖恩在评论中指出的描述。在

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


Tags: thetorightan编辑coordinateisposition
1条回答
网友
1楼 · 发布于 2024-09-30 16:23:21

坐标是连续的字符对。要将它们转换成数字,您需要从每个字符中减去相当于字符“R”=82的ascii。在您的示例中,“UM”转换为(3,-5),因为U是ascii码85。减去82(‘R’)得到3。M是ascii码77,减去82得到-5。在

相关问题 更多 >