I couldn't come up with a more elegant way of drawing any color font from a single bitmap (png) font loaded in memory.

The only way I could get it to work was to render everything into a buffered image, which is then modified at pixel level by the font drawing.

The only other way I can think of how to do this would be to create the buffered image, then steal its array, and have to do my own pixel copying / color operations from there on instead of using drawImage calls... But I'd really like to avoid going that far if I could!

Also, make sure you reset the AlphaComposite to what it was previously after drawing the rect.

Oh wait, you're assuming that I'm rendering text to a image which gets drawn to another image, I think... which would explain why none of this is working because I'm just drawing the text (bitmapped font) directly onto the canvas.

So I'm guessing this would work if I was using a BufferedImage just for text rendering, clearing it to black every frame () and then using alpha composite to draw that to the canvas.

oh are you saying to do all of that within one frame, per text && text_color?

so if i wanna draw something in red, then something in orange, i'm "drawing the letters, setting the composite, setting the color, filling the image, drawing the image, clearing the image" once for red, and once again for orange (all in the same rendering frame)

Let's say I want to draw a string of information in red, and then later (somewhere else, in some other class or on some other GUI window) in a completely separate function call, I want to draw a string of information in orange.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org