ivanceras / svgbob

Convert your ascii diagram scribbles into happy little SVG
http://ivanceras.github.io/svgbob-editor/
Apache License 2.0
3.88k stars 109 forks source link

CJK characters Error #5

Closed erasin closed 8 years ago

erasin commented 8 years ago

convert "测试" and the second char will be cover the first char in svg.

1 <---test测试--> 测试test
         \
          \
           '-> 测试test

svgbob < test.bob > test.svg

svg :

<svg font-family="Electrolize,Titillium Web, Trebuchet MS, Arial" font-size="14" height="80" width="168" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="triangle" markerHeight="10" markerUnits="strokeWidth" markerWidth="10" orient="auto" refX="0" refY="5" viewBox="0 0 14 14">
<path d="M 0 0 L 10 5 L 0 10 z"/>
</marker>
</defs>
<style>

     <![CDATA[ 
    line, path {
      stroke: black;
      stroke-width: 1;
    }
     ]]> 

</style>
<path d=" M 16 24 L 32 24 M 64 32 L 80 64 L 82 68 A 8 8 0 0 0 88 72" fill="none"/>
<path d="" fill="none" stroke-dasharray="3 3"/>
<line marker-end="url(#triangle)" x1="16" x2="12" y1="24" y2="24"/>
<line marker-end="url(#triangle)" x1="96" x2="108" y1="24" y2="24"/>
<line marker-end="url(#triangle)" x1="88" x2="100" y1="72" y2="72"/>
<text x="2" y="28">
1
</text>
<text x="34" y="28">
-test测
</text>
<text x="82" y="28">
试
</text>
<text x="90" y="28">
-
</text>
<text x="122" y="28">
测
</text>
<text x="130" y="28">
试
</text>
<text x="138" y="28">
test
</text>
<text x="114" y="76">
测
</text>
<text x="122" y="76">
试
</text>
<text x="130" y="76">
test
</text>
</svg>

> ```
ivanceras commented 8 years ago

Thanks for opening an issue, I'll try to support your use case.

erasin commented 8 years ago

I regret that the problem remains. you cant test it

+----------------------+
|                      |
|       中文处理         |
|                      |
+----------------------+

The vertical line is not closed.

I'm review your code, Try to fix the bug.

ivanceras commented 8 years ago
+----------------------+
|                      |
|       中文处理       |
|       12345678       |
|                      |
+----------------------+

The problem is that the chinese characters occupies 2 spaces visually, but only counted as 1 character.

The Grid assumes only 1 space occupied per character. A rewrite will have to be done in order to solve this bug.