Fix duplicate faces when loading fonts from a directory - #754
Open
ChrisJr404 wants to merge 1 commit into
Open
Conversation
`load_fonts_from_paths` shared a single accumulator across every scanned font and never cleared it, and each callback re-scanned the whole file, so every face was re-registered on later callbacks (and multiplied further for collection files). Register the font that `scan_paths` already parsed directly instead of re-scanning, giving each callback its own accumulator.
ChrisJr404
force-pushed
the
fontique-dedup-load-fonts-from-paths
branch
from
August 26, 2026 03:10
6a92cfa to
90fd270
Compare
Member
|
Welcome! Unfortunately this code is a little bit outside of my wheelhouse to review quickly. However, I'd just like to understand your workflow here - we have a recently introduced PR template, which you haven't followed. What tool did you use the open this PR? It might be worth reporting to them that they didn't surface the PR template properly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #683.
load_fonts_from_pathskept a singlefamiliesmap for the whole scan and never cleared it, then re-merged the entire map intoself.familieson every callback, so each face got re-added on later callbacks. On top of that it re-scanned the whole file withscan_memoryeven thoughscan_pathshad already parsed the font, which multiplied the duplicates further for collection (.ttc) files.This registers the font that
scan_pathsalready handed us directly and gives each callback its own accumulator, so every face lands exactly once.register_fontsstill scans the memory blob it is given, but now goes through the same per-font registration path.Added a regression test that loads the system font directory and checks that no family ends up with a duplicate face (same source and index). It is gated the same way as the existing
make_shared_matches_localtest and returns early when no font directory is present.