Register
4coder»Forums»How does the text rendering work?
8 posts
How does the text rendering work?
1 month, 1 week ago Edited by Terans on March 7, 2021, 9:47 p.m. 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
11 posts
How does the text rendering work?
1 month, 1 week ago
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
24 posts
How does the text rendering work?
1 month, 1 week ago Edited by Leonardo on March 8, 2021, 6:03 p.m.
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
979 posts
How does the text rendering work?
1 month, 1 week ago
I think 4coder creates a new atlas when you change the font size. Scaling the quads will quickly degrade quality of the text rendering.