I'm building a text editor for Windows. I use the DirectWrite rasterizer to generate very high quality font bitmaps. To write text, I passed bitmaps to OpenGL shaders with an array of texture coordinates and quad offsets and called glDrawArraysInstanced.
The problem is that ClearType font bitmaps are tied to specific backgrounds.
This means that if the user wants to use multiple font colors on different backgrounds with different font sizes, I need to generate a ton of textures:
# of ClearType bitmaps = (# of backgrounds) * (# of colors) * (# of sizes)
This is not a problem in GrayScale rendering where the color can be passed to the shader and the background is transparent:
# of GrayScale bitmaps = (# of sizes)
I find this problematic because the user could inadvertently slow down the program. And then, there is the limit of the textures that you can adapt to a single shader …
I would like to support both rasterization methods.
- Is there a way to solve the problem gracefully?