beyond-all-reason / beyond-all-reason/RecoilEngine
Refactor font code for better glyph searches
- Dominant language
- C++
- Stars
- 683
- Forks
- 293
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 40
Description
Recently a few PRs have been introduced to optimize glyph search:
- https://github.com/beyond-all-reason/spring/pull/2009
- https://github.com/beyond-all-reason/spring/pull/2011
- https://github.com/beyond-all-reason/spring/pull/2012
- https://github.com/beyond-all-reason/spring/pull/2013
Some are fixes, but others are a critical workarounds/improvements for recently discovered critical problems with glyph search performance. (some more in-depth info at [#2012](https://github.com/beyond-all-reason/spring/pull/2012)).
There is still some space for improving this through avoiding pattern recreation and duplicate searches being done now, both from LoadWantedGlyphs and CTextWrap::SplitTextInWords. Also, since the changes have been somewhat hurried, there is space for some refactoring detected while introducing these.
This issue is here to allow discussion and provide a plan forward:
- [x] Make MAX_RECENT_FONTS configurable (PR [#2067](https://github.com/beyond-all-reason/spring/pull/2067))
- [x] Make all fontname-size caches use the same key structure, be it `std::pair` or similar struct. (PR [#2189](https://github.com/beyond-all-reason/spring/pull/2189))
- currently some are using std::string,int struct, but others are doing stringify(name+size).
- [x] Maybe refactor new config variable management from FtLibraryHandler to CFontTexture. (PR [#2413](https://github.com/beyond-all-reason/spring/pull/2413))
- [ ] Introduce a "search context" object, where we can initialize and maintain temporal search cache, this can later be used inside CTextWrap and anyone repeatedly calling LoadWantedGlyphs, also LoadWantedGlyphs can use this to pass into GetFontForCharacters, thus avoiding expensive pattern preparation, and repeated search.
Note the plan is subject to change as discussion and implementation moves forward.
Don't hesitate to comment here any ideas, objections, suggestions or whatever you feel like will add to the implementation and discussion.
Contributor guide
Assessment
This issue has not been assessed yet.