beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
222 stars 102 forks source link

Mechanism to define priority fallback fonts #1777

Open saurtron opened 4 days ago

saurtron commented 4 days ago

Work done

Related issues

While this PR won't directly fix all of the above, the proposed mechanism will allow fixing all those easily by having games providing priority fallback fonts for languages and emojis, and using the proposed api.

Discussion

How to test

The general procedure is finding a few characters you know render different on your os and some other font. Try without the fallback, then try with fallbacks.

fc-list or some similar program can be used to list fonts your os has with some character, like: fc-list :charset=27f5, fc-list :charset=1f81a or fc-list :charset=1F525.

sprunk commented 4 days ago

Not sure where the documentation for the lua methods should go, I don't see it for LoadFonts or DeleteFont, I'll take a look.

It goes above the function but there's an ongoing effort to change its format, see #1775.

saurtron commented 4 days ago

ongoing effort to change its format

Ok for now I added ldoc format since it's what's used currently, I'll keep an eye on the conversion effort in case I need to change this, or to let them know to convert this too.

Actually the font module is not included into the ldoc generation, but I think adding it should go into a different PR.

saurtron commented 3 days ago

Changed the search mechanism a bit to first search our fallback fonts and then the system ones, since after some testing I found out fontconfig otherwise still sometimes prioritizes unexpectedly (for example it kept choosing note emoji colour instead of my selected note emoji regular, even when the search pattern looked like it should prioritize the regular one).

I'll keep testing patterns to try and revert to the old search mechanism but not sure it will be feasible due to how fontconfig works, also current way is a bit more efficient when priority fallbacks are defined since it will at first be searching only on the game font list, and only resort to search on the system fonts when needing it.