Skip to content

Conversation

@slipher
Copy link
Member

@slipher slipher commented Oct 5, 2025

Remove unused font-related definitions. NUKE an unused file format with .dat extension for pre-rasterized fonts. NUKE the font handle table since we only load one font. Move font stuff out of q_shared.h, the header included by everything engine and gamelogic.

faceData might not be valid at the point it hits the warning
"RE_RegisterFont: Unable to read font file %s".
RE_Glyph(), fontInfo_t::height, fontInfo_t::glyphScale, a couple macros
The lengthy comment which is also deleted here explains that once upon a
time, pre-rasterized fonts were shipped with Q3A to work around
licensing issues with FreeType. The file format being NUKED here was a
binary format with a .dat extension, which just specified size, tex
coords, etc. for 256 glyphs; the rasterized images were stored in other
files.
We only load one font, one time - the console font. No need for a font
table caching system to detect duplicate font load requests.
@illwieckz
Copy link
Member

We only load one font, one time - the console font. No need for a font
table caching system to detect duplicate font load requests.

How the cgame does to load a font?

@slipher
Copy link
Member Author

slipher commented Oct 6, 2025

We only load one font, one time - the console font. No need for a font
table caching system to detect duplicate font load requests.

How the cgame does to load a font?

It has its own copy of the Freetype library. Font rasterization is done entirely inside the cgame.

Copy link
Contributor

@necessarily-equal necessarily-equal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change LGTM, didn't test

}

void RE_UnregisterFont_Internal( fontHandle_t handle )
void RE_UnregisterFont( fontInfo_t *font )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would kind of suggest having a

Suggested change
void RE_UnregisterFont( fontInfo_t *font )
void RE_UnregisterFont( fontInfo_t **font )

That then sets *font = nullptr; — I think the current code is correct and unlikely to change, so this extra safety doesn't do much difference. Feel free to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll pass on that - this style of freeing function seems a little wonky since most deallocation functions like free or delete don't do that. And I caused a crashing bug one time by implementing this style of deleting function in the particle code... If we want to make it any safer probably RAII with unique_ptr is the way to go.

@illwieckz
Copy link
Member

How the cgame does to load a font?

It has its own copy of the Freetype library. Font rasterization is done entirely inside the cgame.

Oh yes, so we had at least 3 copies of the same font in memory, and I was wondering why our game was so hungry…

@slipher slipher merged commit b2cb13d into DaemonEngine:master Oct 8, 2025
9 checks passed
@slipher slipher deleted the font-cleanup branch October 8, 2025 07:39
@necessarily-equal
Copy link
Contributor

(cf #1844)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants