Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#1117 closed enhancement (fixed)

Replace unifont interface with CFontManager

Reported by: historic_bruno Owned by: philip
Priority: Nice to Have Milestone: Alpha 15
Component: Core engine Keywords: hmgr, font, simple
Cc: Patch:

Description

Font textures and associated data are currently handled by unifont, which is a low-level C style wrapper around the h_mgr system. It would be better if we had a CFontManager instead to abstract this and provide a central point for loading and reloading fonts (useful for fixing #741). It would mirror other managers we have like CTextureManager and CShaderManager. gDEBugger also indicates we're leaking font textures, maybe implementing this would provide a better means of cleaning them up?

Change History (4)

comment:1 by Philip Taylor, 12 years ago

Possibly relevant recent change: all the code that rendered text with unifont has now been changed to use the new CTextRenderer, which provides a more appropriate level of abstraction. Some still uses CFont directly to get text metrics (line spacing, character width, etc) - it'd probably be best to expose that data via CTextRenderer somehow, so nothing else needs to use CFont.

Then I think it'd probably be best to delete CFont and unifont, create a new CFont that contains the old unifont file-loading functionality directly (and then it can use CTextureManager instead of raw ogl_tex, for improved consistency and compression support etc), and create a new CFontManager that is a simple global cache of CFonts (probably accessed by CTextRenderer as g_Renderer.GetFontManager()).

comment:2 by Philip Taylor, 12 years ago

Keywords: simple added

comment:3 by philip, 11 years ago

Owner: set to philip
Resolution: fixed
Status: newclosed

In 14016:

Refactor text renderer

Replace unifont with CFont and CFontManager, since the h_mgr interface was
needlessly inconvenient.

Load the font textures through CTextureManager, to support dynamic
reloading (e.g. when resetting GL state - see #741).

Add CFontMetrics as a convenient wrapper for code that just wants to
measure text.

Fixes #1117.

comment:4 by fabio, 11 years ago

Milestone: BacklogAlpha 15
Note: See TracTickets for help on using tickets.