You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Objective
The `FontAtlasSets` resource contains a map from `AssetId<Font>`s to
`FontAtlasSet`s.
`FontAtlasSet` has another map from a `FontAtlasKey` (tuple of the font
size bit cast into a `u32` and `FontSmoothing`) to a vec that contains
the actual font atlases for the font. The redirection through the
additional map doesn't serve much purpose, only individual fonts are
looked up (except when freeing unused fonts), not the set of all atlases
for a particular font face.
## Solution
* Remove `FontAtlasSet`.
* Rename `FontAtlasSets` to `FontAtlasSet`.
* Add `AssetId<Font>` to `FontAtlasKey`.
* Change the font atlas map to a `HashMap<FontAtlasKey, Vec<FontAtlas>>`
* Move the `FontAtlasSet` methods `add_glyph_to_atlas`,
`get_glyph_atlas_info`, and `get_outlined_glyph_texture` into the
`font_atlas` module and rework them into free functions.
* Change `FontAtlasSet` into a newtype around the map and remove the
manual method implementations in favour of deriving `Deref` and
`DerefMut`.
We could consider renaming `FontAlasSet` to `FontAtlasMap`, but it
doesn't seem necessary, and mathematically a map is a set so it's not
incorrect.
## Testing
The output from all of the text examples should be unchanged.
Naive benchmarks suggest this is a modest improvement in performance at
a very high load (5% ish), but this is more about reducing complexity to
make more significant optimisations possible. Freeing the unused atlases
when a font asset is removed will be slower, it has to filter all the
font atlas vecs now instead of just removing the entry for the font
asset, but this isn't done very often and the number of entries should
be relatively low.
---------
Co-authored-by: Dimitrios Loukadakis <[email protected]>
0 commit comments