Open saurtron opened 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.
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.
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.
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
gl.
namespace which is a bit awkward maybe.gameFontSet
, first searching on it with FcFontSetSort, and then falling back to FcFontSort to search system fonts, this allows having our own set in addition to the fontconfig ones with minimal changes.fallbackPattern
, this seems to work fine.FcConfigSubstitute(FtLibraryHandler::GetFCConfig(), pattern, FcMatchScan)
after adding the font to our set. I see the library doing this when it adds fonts through FcConfigAppFontAddFile, but tbh have no idea if it's actually needed in this case, on my tests it doesn't seem to help or hurt.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.Added ldoc, will keep an eye for https://github.com/beyond-all-reason/spring/pull/1775How 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
orfc-list :charset=1F525
.