This glyphs of the characters are extracted and the glyph's coordinates are converted to spatial coordinates. That's it. Uses opentypes.js to read font files. Live demo app: https://sreekmtl.github.io/textToGeoJSON-demo/
npm install texttogeojson
import textToGeoJSON from 'texttogeojson'
await textToGeoJSON(text, fontPath, anchorPoint, options).then(geojson=>{
//rest of the code
})
text
: String to convertfontPath
: path to ttf/otf filesanchorPoint
: [X, Y] Only supports EPSG:3857 (Web mercator projection) as of nowoptions
: { textSize: Number, smoothness: Number (Number of points in a bezier curve) }
I haven't tested all kinds of fonts yet. Right now it only reads M,L,Q, C and Z of glyph paths. Only tested with ttf and otf fonts yet.