Pomax / lib-font

This library adds a new Font() object to the JavaScript toolbox, similar to new Image() for images
MIT License
731 stars 72 forks source link

Uploading font #30

Closed nejc001 closed 4 years ago

nejc001 commented 9 years ago

Hello, im using a canvas, where i can upload images into, simple with Image() object, by setting the readed data (by using FileReader) to image.src. With that i can simply upload the image.

Image example: var imgObj = new Image(); imgObj.src = event.target.result;

Font.js doesnt support exactly this, so you can't simply load them on site, like the images, because it doesnt support the font.src.

So my question is, is it even possible to upload font on site, if yes, how to set FileReader's data to Font()?

Thank you

Pomax commented 9 years ago

Small technical correction: when users drop a file into a webpage, that's not an upload yet (it's only an upload if that data is sent to your server).

That said, you're right: Font.src is a passthrough to the internal .url property which looks like it only checks whether it needs to either download, or load as system font, so it's missing the check to see if a BASE64 encoded string resources was dropped into it. Marking as bug.

Pomax commented 4 years ago

obsolete with the 2019 rewrite