shrhdk / text-to-svg

Convert text to SVG path without native dependence.
Other
978 stars 132 forks source link

getPath return partial data and serie of NaN #22

Closed edouard-lopez closed 7 years ago

edouard-lopez commented 7 years ago

related: #23

Env

Code

import TextToSVG from "text-to-svg";

const textToSVG = TextToSVG.loadSync(
  "./resources/fonts/NotoSansTC-Regular.otf"
);
const svg = textToSVG.getSVG("yǐn");
console.log(svg);

Output:

$ node --require babel-core/register ./debug.js 
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="101.30400000000002" height="106.56000000000002"><path d="M0-7.13L4.61-7.13L4.61-13.68C8.57 3.67 4.82NaNNaNNaNLNaNNaNLNaNNaNLNaNNaN"/></svg>

Error

Above is a short snippet that reproduce the but, in the context of my app I got more info:

yǐn <path fill="black" stroke="black" id="annotation" d="M39.24 15.98L40.26 15.98L40.26 14.52C41.14 18.38 40.31NaNNaNNaNLNaNNaNLNaNNaNLNaNNaN"/>
already exists
Error: Got an error parsing the glyph "㐆": Unexpected character "N" at index 54..
    at SAXStream.<anonymous> (/data/projects/hanzi-pinyin-font/node_modules/svgicons2svgfont/src/index.js:245:29)
    at emitOne (events.js:96:13)
    at SAXStream.emit (events.js:188:7)
    at Object.me._parser.(anonymous function) [as onopentag] (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:258:17)
    at emit (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:640:35)
    at emitNode (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:645:5)
    at openTag (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:841:5)
    at Object.write (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:1305:13)
    at SAXStream.write (/data/projects/hanzi-pinyin-font/node_modules/sax/lib/sax.js:239:18)
    at Readable.ondata (_stream_readable.js:555:20)
(node:4788) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'svg' of undefined
Done in 2.25s.
edouard-lopez commented 7 years ago

Using DroidSansFallbackFull fixed my problem.