# Is it reasonable to use FreeType [closed]

Won't it slow my game if I use FreeType lib and convert 2 fonts from .ttf instead of using preloaded BitmapFont .png? Or may be FreeType so fast, that I can use fonts both ways? All I need is to change color and size of my text. P.S. I use 3 fonts in my project

• Voting to close, as answers will be entirely opinion based. What's "too slow" will always be subjective to the application. Decoding a freetype font 60 times a second will probably be too slow, while loading the font once at startup will probably make no difference, but anything in between will always depend on the application, the font and everything else. Loading the png may even take more time than loading the font. – Riot May 6 '17 at 22:03
• @Riot, so to answer "will it slow my application", your saying "yes". I don't see any requirement for "too" slow, here. VTLO. – Gnemlock May 7 '17 at 0:17
• I'm not saying "it will slow your application", though. Loading a font takes time, but that can be done once, costing you a one-off 5ms at the start and that's it - or it can cost you a ton of time if you keep loading new fonts, it depends entirely on how you're implementing it. Loading a png costs you time, too. Anything your application does will "slow it" from a logical point of view. There can be no general answers here. – Riot May 7 '17 at 12:13

A solution which I found quite handy in various projects was to have a TextRenderingCache class to manage cached font renderings. It usually has a hash table with string plus render settings (font, color, size, etc.) as key and a texture with the rendering as value. When a given rendering is requested from the TextRenderingCache class, it checks if it already has that rendering, and if not it creates one. Dropping renderings from the hash-map which were not used for several seconds to avoid memory leakage is optional (some games need this, some do not).