rcarmo / pngcanvas

A minimalist library to render PNG images using pure Python
MIT License
44 stars 9 forks source link

Cannot write text to image canvas #9

Open IAbstract opened 8 years ago

IAbstract commented 8 years ago

I need to write text values to a canvas. I do not see how this will work with the current API. Is this a planned feature?

Thanks, David Boarman

rcarmo commented 8 years ago

Hi there!

Back when I wrote the first version, I ended up doing that with a separate bitmap and copying the characters into position using copyRect. It's fairly easy to do with a monospaced font or for the ASCII set if you use an auxiliary array with the character widths (I usually only needed to render digits and a comma to annotate simple charts).

If you need more than that, well... It wasn't in scope or a match for the original requirements, so I'd say it's not planned at this point either (@BYK may have done something about this, but I'm not sure).

IAbstract commented 8 years ago

Thanks for the response ... but this is for a business card designer so fonts, colors, styles, weights, etc. all need to be accounted for. I may work on a hybrid of html2canvas.js for text values.

Does this scenario sound feasible with pngcanvas:

  1. receive multiple images from the web page with position and size values
  2. copy those images to rectangles within a parent canvas object
  3. save composed image to .png

Thanks again, David