Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support supplying mobile fallback fonts by style with caching
This pull request builds on top of fallback font support on iOS by including the ability to provide fallback fonts based on the styling of the missing character. Currently, the style information only contains weight. This weight is grabbed by calling `getAxisValue`. According to Luigi, this is a linear search, so perhaps there's room for a performance optimization later on. There is one lower-level C++ change: `gFallbackProc` returns the font for the missing character, in addition _to_ the missing character (as a second parameter). This font will be used to generate the requested styling within the iOS runtime. This adds a new class property to `RiveFont`: `fallbackFontCallback` (whose name I'm open to changing). This is a block (i.e closure) that will be called when a fallback font is requested. It supplies the styling of the missing character so that, for example, different fonts can be used based on the weight of the missing character. For example usage, see `SwiftFallbackFonts.swift`. This provider is what's used under-the-hood, and utilizes the pre-existing `fallbackFonts` class property The "trickiest" bit here is the caching. NSDictionary requires equatable / hashable types as keys, and we want to minimize additional generation of a Rive font, so we cache any used fonts in a wrapper type, used as the value. When new fallback fonts are provided, either directly or when a new provider block is set, the cache will be reset. Once the weight is determined, generating the right key is as simple as calling the right initializer, and when set, generating the right value is simple as calling the right initializer with the created Rive font. Finally, `RiveFactory` was getting a little bloated, so I did a little file cleanup. This pull requests also includes Android support from #8621 Diffs= 7986d64d83 Support supplying mobile fallback fonts by style with caching (#8396) fb8ecf3552 fixed url for canddiates and goldens in not pack mode (#8649) 4b82cf2e91 treat remapped animations as always settled (#8643) d7db032e08 update measure function to use its text wrap and max size (#8640) 406e938c3d add support for standalone custom properties to bind values to (#8634) 8f3b760a6c Dx11 support (#8577) Co-authored-by: David Skuza <[email protected]> Co-authored-by: Umberto <[email protected]> Co-authored-by: Umberto Sonnino <[email protected]>
- Loading branch information