shrhdk / text-to-svg

Convert text to SVG path without native dependence.
Other
974 stars 131 forks source link

Error: Text data outside of root node. #23

Closed edouard-lopez closed 7 years ago

edouard-lopez commented 7 years ago

related: #22

Data

This is the glyph I tried to convert to svg:

[
  { "codepoint": "U+3405", "ruby": "wǔ", "glyph": "㐅" },
  { "codepoint": "U+3406", "ruby": "yǐn", "glyph": "㐆" }
]

Problem

I got the following error even when first and second element are the same.

$ node --max_old_space_size=8192 --optimize_for_size --max_executable_size=4096 --stack_size=4096 --require babel-core/register ./index.js 
----
㐅 /wǔ/
<path fill="black" stroke="black" id="glyph" d="M47.20 67.60L104.80 67.60L104.80-4.40L47.20-4.40ZM76 28.65L53.10-0.80L98.90-0.80ZM78.30 31.60L101.20 2.15L101.20 61.05ZM53.10 64.00L76 34.55L98.90 64.00ZM50.80 2.15L73.70 31.60L50.80 61.05Z"/>
<path fill="black" stroke="black" id="annotation" d="M41.51 17.56L43.22 17.56L44.44 12.90C44.66 12.07 44.84 11.26 45.03 10.38L45.11 10.38C45.32 11.26 45.48 12.06 45.70 12.87L46.97 17.56L48.73 17.56L51.06 8.87L49.69 8.87L48.41 13.90C48.22 14.73 48.06 15.51 47.86 16.33L47.80 16.33C47.59 15.51 47.40 14.73 47.19 13.90L45.83 8.87L44.41 8.87L43.06 13.90C42.84 14.71 42.66 15.51 42.47 16.33L42.39 16.33C42.23 15.51 42.06 14.73 41.88 13.90L40.58 8.87L39.10 8.87ZL41.34 23.72M41.48 13.24L42.94 13.24"/>
----
㐅 /wǔ/
<path fill="black" stroke="black" id="glyph" d="M47.20 67.60L104.80 67.60L104.80-4.40L47.20-4.40ZM76 28.65L53.10-0.80L98.90-0.80ZM78.30 31.60L101.20 2.15L101.20 61.05ZM53.10 64.00L76 34.55L98.90 64.00ZM50.80 2.15L73.70 31.60L50.80 61.05Z"/>
<path fill="black" stroke="black" id="annotation" d="M41.51 17.56L43.22 17.56L44.44 12.90C44.66 12.07 44.84 11.26 45.03 10.38L45.11 10.38C45.32 11.26 45.48 12.06 45.70 12.87L46.97 17.56L48.73 17.56L51.06 8.87L49.69 8.87L48.41 13.90C48.22 14.73 48.06 15.51 47.86 16.33L47.80 16.33C47.59 15.51 47.40 14.73 47.19 13.90L45.83 8.87L44.41 8.87L43.06 13.90C42.84 14.71 42.66 15.51 42.47 16.33L42.39 16.33C42.23 15.51 42.06 14.73 41.88 13.90L40.58 8.87L39.10 8.87ZL41.34 23.72M41.48 13.24L42.94 13.24"/>
Error: Text data outside of root node.
Line: 7
Column: 7
Char: ;
    at error (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:667:10)
    at strictFail (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:693:7)
    at Object.write (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:1048:15)
    at SAXStream.write (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:239:18)
    at Readable.ondata (_stream_readable.js:555:20)
    at emitOne (events.js:96:13)
    at Readable.emit (events.js:188:7)
    at Readable.read (_stream_readable.js:381:10)
    at flow (_stream_readable.js:761:34)
    at resume_ (_stream_readable.js:743:3)
Done in 2.22s.

Even if I try with latin alphabet and number I got the issue:

[
  { "codepoint": "U+3405", "ruby": "123", "glyph": "a" },
  { "codepoint": "U+3406", "ruby": "456", "glyph": "b" }
]

Question

Do you have an idea?

edouard-lopez commented 7 years ago

Using DroidSansFallbackFull fixed my problem.