-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mechanism to define priority fallback fonts #1777
Conversation
and ClearFallbackFonts.
It goes above the function but there's an ongoing effort to change its format, see #1775. |
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. |
can still sometimes have it's own priorities.
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. |
This is only safe to do on recent fontconfig versions.
Does #1790 supersede this one? |
Yes, although I left this one so both can be compared so its easier to see the two implementation steps, also in case atlas refresh has some problem could always fall back to this one. |
This PR is for reference only, I think it's better to merge #1790 directly (this PR also contained there).
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.
Testing
You will notice disabling doesn't really work well, for the branch where fallbacks are enabled and disabled, use this branch instead: #1790
You can further play with it by using left mouse button to enable/disable fallback, and writing your own characters into chat.
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 Convert LDoc to lua-language-server #1775More notes on testing
(for a direct procedure see "Testing" above)
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
.