We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Draw text on an image and without java.awt.font
Page Index Toggle Pages: 1
Draw text on an image and without java.awt.font? (Read 905 times)
Draw text on an image and without java.awt.font?
Feb 14th, 2010, 5:11pm
 
Hi,

I am in an environment (Google Appengine) that disallows java.awt.* and a couple of other important classes. In my program I draw text-captions on an image using Graphics2D. Also I would like to be able to convert text into something like a Java2D Shape.

I wonder if I could use Processing to rewrite my program without these missing dependencies. Are there libraries that replace the default Java graphics system?

Thanks,
sb
Re: Draw text on an image and without java.awt.font?
Reply #1 - Feb 15th, 2010, 2:13am
 
Graphics2D is part of java.awt.
So are all graphics, from shapes to GUI...
Processing relies on AWT too.
So, unless you rewrite (or take) big part of AWT, at least to manage off-screen buffer drawing, you are a bit stuck.
Unless Processing.js is solution? You don't give much information on how you plan to use your graphics.
Re: Draw text on an image and without java.awt.font?
Reply #2 - Feb 15th, 2010, 1:48pm
 
Thanks...I guess I am out of luck.

Basically I wanted to draw a caption (text) at the bottom of an image using Java.
Re: Draw text on an image and without java.awt.font?
Reply #3 - Feb 15th, 2010, 9:20pm
 
If you can use loadImage(), then a possibility is to make your own text renderer...

Save an image with all the characters in it in a nice grid (or even a long strip), and in your code have an array storing the positions of characters (or some function that maps a character value to the image location).

I just recently saw a post somewhere (sorry, didn't take a note of where!) mentioning bitmap text, which I think used "red dots" to mark the positions of the characters. So, I suppose you could have the image itself encode the character locations, and have your program look for the markers in the image.

Suppose a font image with black background and "white" (maybe even multi-coloured!) text. You could use the blend() method to copy individuals characters from the font image to your output image, or "by hand" copy individual pixels as you see fit.

-spxl
Page Index Toggle Pages: 1