The International Simutrans Forum

Development => Patches & Projects => Topic started by: ceeac on April 22, 2026, 05:33:23 PM

Title: Refactor font metrics
Post by: ceeac on April 22, 2026, 05:33:23 PM
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).
Title: Re: Refactor font metrics
Post by: prissi on April 23, 2026, 12:45:01 PM
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.