Releases font resources and removes from memory.
Takes font (font handle from b2dLoadFont to free, positive integer).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
fontInt
Returns
Void
Quick Summary
Releases font resources and removes from memory.
Takes font (font handle from b2dLoadFont to free, positive integer).
Returns nothing.
Technical Exegesis...
Releases font resources and removes from memory. Takes font (font handle from b2dLoadFont to free, positive integer). Returns nothing. Deletes font texture atlas from GPU memory, removes font from internal font map, invalidates font handle (subsequent use will be ignored).
Memory management: frees GPU texture memory (font atlas bitmap), frees CPU memory (font metrics, character data), immediate release (no deferred cleanup), handle becomes invalid after free (reuse causes no error but no rendering).
Releases font resources and removes from memory. Takes font (font handle from b2dLoadFont to free, positive integer). Returns nothing. Deletes font texture atlas from GPU memory, removes font from internal font map, invalidates font handle (subsequent use will be ignored).
Memory management: frees GPU texture memory (font atlas bitmap), frees CPU memory (font metrics, character data), immediate release (no deferred cleanup), handle becomes invalid after free (reuse causes no error but no rendering).
Use cases: (1) Cleanup on exit (free all loaded fonts before shutdown), (2) Dynamic font management (load/free fonts as needed per scene), (3) Memory optimization (free unused fonts to save VRAM), (4) Font switching (free old font before loading new one).
Common patterns: cleanup = b2dFreeFont(myFont): myFont=0; scene transition = b2dFreeFont(menuFont): gameFont=b2dLoadFont("game.ttf", 24); conditional free = If myFont<>0 Then b2dFreeFont(myFont): myFont=0 EndIf.
Error handling: silently ignores invalid handles (handle not in font map, no error), safe to call multiple times (subsequent calls have no effect), no crash if font still in use by queued draw commands (commands reference font data directly).
Memory impact: typical font consumes 1-4MB GPU memory (depends on character set and size), freeing multiple fonts can significantly reduce VRAM usage, font texture atlas size depends on font size and character count.
Best practices: free fonts when no longer needed (not every frame), set handle to 0 after free (avoid dangling references), free in reverse load order (last loaded first freed), ensure no draw commands reference freed font.
Related: b2dLoadFont loads font file, b2dDrawText uses font for rendering, b2dDrawTextInt/b2dDrawTextDouble use font for rendering, b2dGetFontWidth queries font metrics.