rougier / freetype-gl

OpenGL text using one vertex buffer, one texture and FreeType
Other
1.65k stars 266 forks source link

Glyph Performance #125

Open cbratschi opened 8 years ago

cbratschi commented 8 years ago

I am wondering why freetype-gl allocates and frees FreeType instance while rendering each and every glyph. Why does it not use shared instances?

I am asking because rendering some lines of text often takes more than 100 ms and therefore leads to dropped frames. Cached FreeType instances should be a lot faster. I am already using fonts stored in memory instead of the file system. The device which I am using is a Raspberry Pi 3. On macOS the impact is less visible but a render cycle still takes more than 10 ms whenever text changes occur.

Also the kerning table is rebuilt after adding a glyph which costs a lot of time as well.

Are there any reasons for the current architecture?

rougier commented 8 years ago

For the freetype instance, yes we could probably cached the instance instead of closing/opening. However, it also depends on how you use the library. If you know the set of glyphs you'll be using, you can cached them at once and then you're done with freetype.

As for the kerning table, it is rebuild because for each new glyph, we need to compute the specific kerning related to this glyph in relation with already loaded glyph.