News:

SimuTranslator
Make Simutrans speak your language.

Refactor font metrics

Started by ceeac, April 22, 2026, 05:33:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ceeac

This patch just moves the functions related to font metrics and font loading from simgraph to font_t with some minor cleanup. Text rendering functions now take a font_t *. This mostly decouples font handling from text rendering and makes it easier to have multiple fonts loaded at the same time (not added in this patch).

prissi

I am very much for decoupling this. However, I see little reasons to support more than two fonts, one for the name language and one for the rest. Especially, given the troubles to have at least ONE open source font to support all languages. Even having a different font for many gui elements, and I see a nightmare of changes looming with that.

Since this adds so much more work to typing, I rather suggest to have normal routines like
calc_text_width() with an extra default paramter defaulting, well, to the default font. Or, have a define like
calc_text_width() which then uses "font_t::default_font->calc_text_width_font(" or so.

Just my feelings, though.