The International Simutrans Forum

 

Author Topic: Font code refactor  (Read 897 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 267
Font code refactor
« on: April 01, 2020, 01:53:21 PM »
This patch refactors font loading and rendering. I also updated variable names to follow the freetype naming conventions from this page where possible.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4898
  • Languages: EN, DE, AT
Re: Font code refactor
« Reply #1 on: April 01, 2020, 02:02:35 PM »
Thanks! What was the reason to work on this?

It would be nice if the font-code would enable larger than 16 x 23 pixels per letter.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10820
  • Languages: De,EN,JP
Re: Font code refactor
« Reply #2 on: April 01, 2020, 11:40:22 PM »
The font system is more broken: There are all the "large_font" remainder, even though there is no small font used anymore. I would also define functions like "get_glyph_height" etc. inline in the "*.h" file, since those are used a lot in the UI code. Especially if they only return a const. Otherwise many compiler will no inline them.

Also no hex fonts used anymore, so one can safely remove this code. (Also the latin2 languages schould probably switch to a bdf font a some point.)

Offline ceeac

  • Devotee
  • *
  • Posts: 267
Re: Font code refactor
« Reply #3 on: April 05, 2020, 01:48:18 PM »
What was the reason to work on this?
Preparation for GPU assisted rendering.

I would also define functions like "get_glyph_height" etc. inline
Done. I have not inlined get_glyph_data etc. because I have not noticed a performance difference and doing it this way is much more readable.

Also no hex fonts used anymore, so one can safely remove this code.
Done.

Offline ceeac

  • Devotee
  • *
  • Posts: 267
Re: Font code refactor
« Reply #4 on: April 18, 2020, 10:44:31 AM »
Patch updated. Notable changes:
  • Fixed crashes when reading corrupted bdf files
  • Fixed debug printing of characters more than 8 pixels wide
  • Fixed compile error when COLOUR_DEPTH==0
  • Removed get_glyph_height
  • Renamed large_font -> default_font in simgraph16.cc
  • Renamed GLYPH_HEIGHT -> GLYPH_BITMAP_HEIGHT
  • Renamed font_t::get_glyph_data -> font_t::get_glyph_bitmap
As far as I am concerned, this is finished now. (I think)

It would be nice if the font-code would enable larger than 16 x 23 pixels per letter.
I can do this in a follow-up patch, I believe this patch is big enough as-is.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10820
  • Languages: De,EN,JP
Re: Font code refactor
« Reply #5 on: April 23, 2020, 03:15:37 PM »
std::min and std::max does not work on my system, so I replace them with min and max. Otherwise committed in r9042, Thank you.