info-beamer

Adding drop-shadow to text

#1

Is there an efficient way to add a soft drop-shadow effect to dynamic text? I was thinking about writing a simple blur shader to achieve this, but the shader API seems to apply to textures. Would I have to write the text to a texture first, or is shader:use applied to any drawing function? Is there a way to stop using the shader afterwards?

#2

Correct. The shader API only works for texture-like objects like image and gl based videos. In the first info-beamer open source release, fonts could also be modified by textures, but due to how text rendering works on the Pi version, that has been disabled. I think it would be pretty difficult right now to do drop shadows: Font is rendered using a font atlas and as such, texture coordinates within a shader would be all over the place.

I think the only viable way would be to have an option to specify drop shadow as a property of the font when loading it (so maybe like resource.load_font{file="foo.ttf", shadow=...}). That way the drop shadow effect would be added while generating the font texture and then rendered without overhead later. Unfortunately that would be a bigger change.

If the drop shadow can be “hard”, maybe rendering the text twice with alpha=.5 and a small x/y offset might work?

#3

Thanks for the info. A “harder” drop-shadow is my fallback. If rendering text is pretty efficient, I may see if I can make a bunch of layers with different offsets and opacities to make it softer, like back in the old days of CSS.