Skip to content

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Oct 2, 2025

Objective

The FontAtlasSets resource contains a map from AssetId<Font>s to FontAtlasSets.
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 face. The redirection through the additional map doesn't serve much purpose, only individual font faces are looked up (except when freeing unused fonts), not the set of all font faces for a particular font.

Solution

  • Remove FontAtlasSet.
  • Rename FontAtlasSets to FontAtlasSet.
  • Add AssetId<Font> to FontAtlasKey.
  • Change the font atlas map to a HashMap<FontAtlasKey, Vec<FontAtlas>>
  • Rework the methods that were on FontAtlasSet into free functions.

Considered 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's last strong Handle is dropped 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.

@ickshonpe ickshonpe added C-Code-Quality A section of code that is hard to understand or change A-Text Rendering and layout for characters D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 2, 2025
@ickshonpe ickshonpe changed the title Remove FontAtlasSet Remove FontAtlasSets Oct 2, 2025
ickshonpe and others added 6 commits October 3, 2025 13:17
@ickshonpe ickshonpe requested a review from rparrett October 4, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Text Rendering and layout for characters C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants