Open kaldrenon opened 5 years ago
They can be used, at least for a browser environment. I use it like this (based on README snippet):
// First argument is URL on web browsers, but it is file path on Node.js.
TextToSVG.load('data:application/font-ttf;base64,SGVsbG8sIFdvcmxkIQ==', function(err, textToSVG) {
const svg = textToSVG.getSVG('hello');
console.log(svg);
});
According to what I read around, only TTF works. Also, if you're on Node, you can use this, but you need to do some hacking:
node_modules
folder;opentype.js
folder;opentype.js/src/opentype.js
;function load(url, callback)
;const loadFn
to always be loadFromUrl
;opentype.js
folder and run npm i
then npm run build
;npm start
, stop it and run it again.
I don't see anything in the documentation about loading a font via data-url, so my guess is that this isn't supported, but I would like to confirm that.
If that is true, is there a suggestion for how I could convert text to a path when I only have the data-url of a font?
If data-urls can be used, could the Readme include an example for how to use it?