4coder»Forums
19 posts
How does the text rendering work?
Edited by Terans on Reason: Initial post
Hi, i wonder how the text rendering works in 4coder. Do you blit a bitmap through OpenGL for every character? And if we want to dynamically resize the font, do you re-rasterize the entire font?
Alexey
16 posts
How does the text rendering work?
Running ldd reveals that fonts in 4coder are rasterized using freetype (at least on linux). Freetype gives you high quality bitmaps, which you then pack into a texture atlas (googlable), probably using something like stb_rect_pack or by hand. This atlas is then uploaded to the GPU, and offsets into this texture are used to draw individual letters.

How font resizing is handled I'm not sure.
Leonardo
21 posts
How does the text rendering work?
Edited by Leonardo on
aolo2
How font resizing is handled I'm not sure.


If the characters in the texture atlas are drawn on top of quads that are sent to the GPU as vertex buffers, then resizing could probably be a simple scaling matrix. Since I don't have much experience on text rendering, this is the only method I'm familiar with.
Simon Anciaux
1337 posts
How does the text rendering work?
I think 4coder creates a new atlas when you change the font size. Scaling the quads will quickly degrade quality of the text rendering.