font and rasterization improvements for ImGui
Summary
Interface "use Freetype to render fonts for ImGui, and use multiple fonts in the ImGui interface"
Purpose of change
Make ImGui use Roboto by default, and the Freetype rasterizer. Load both the configured gui font and the normal monospaced font for use by ImGui. Make item descriptions use the mono font for drawing ASCII artwork. Configure hinting so that Terminus and unifont don’t look awful.
Fixes #76420
Testing
Check out the artwork for a pistol or something.
Additional context
This is a draft for a reason: I need someone who builds on Windows and/or Mac to give me the right CFLAGS/LDFLAGS for linking against Freetype2
Is there a particular reason for adding a new font to the mix, and are there any issues with including Apache licensed material in a cc-by-sa 3.0 project?
Good questions. Yes, the reason for adding Roboto is that it is a proportional font. We could pick from quite a selection, but Roboto was ready to hand, appropriately licensed, inoffensively styled (not deliberately weird or thematic, or deliberately bad like Comic Sans, etc), and has relatively thick strokes even at small font sizes (which makes it render well even if we stick to the default STB rasterizer which cannot do any hinting). And of course the user can override the choice if they prefer something else.
Apache 2.0 is completely compatible with the Creative Commons license, and it meets the definition of an Open Source license.
I guess it builds fine on OSX. Anyone want to give it a try and make sure it works?
Weird. It compiled just fine on Windows while it was a draft…
It's broken at the macOS build referencing imgui so I'm assuming this isn't a random failure?
I wish it were. It's been more than 15 years since I did any development on OSX, and I never had to dig too deep into the build system on that project. I don’t have a Windows machine either. I’d appreciate some help getting this patch to work on those platforms from anyone who has the time.
I spent a little time last weekend trying to find documentation on the subject, but didn’t make much headway. I didn’t really want to spam the CI system with guesses, but on the other hand the only guess I have is to add -lfreetype to the LDFLAGS and hope for the best.
@db48x I took a look. does not compile on VS2022. VS2022 does not like your usage of '__attribute__((unused))'. Instead it prefers the C++17 '[[maybe_unused]]'. If we can't use C++17 across the board, maybe consider a preprocessor definition?
Oops, sorry about that. It looks like I fixed that last week and then just never pushed it. Must have gotten distracted.
A little improvement:
Crap I misread this and thought it was no longer breaking Mac builds.
Hi @db48x I realize this is super, super late... but can I ask what motivated the choice of Roboto-Medium? I just spent a while chasing down what's going on in this menu only to find out that the | and . characters are simply how Roboto-Medium renders them. (I used this to compare the characters outside of the game's rendering pipeline)
(Side note, the mismatched lines is because we were previously relying on utf8width. I can mostly paper over that: )
I don't want to say "Hey, let's change the font again! A year after the last change! (which itself had 3 changes in as few months)"... but it is pretty ugly here. So just looking for your opinion, thanks.
For comparison, unifont looks absolutely great:
(It also plays nicely with utf8width!)
I gave my reasons in a previous comment.
If you just want the health bars to make an actual column, then put them in the second column of the menu entries. Instead of calling uilist::addentry, call uilist::addentry_col.
If you want the health bars to look more like bars, might I suggest changing what characters we use? What if we used ██▃▁▁ or ██▍ ?