Conversation
Guard the registerFamily insertion path with a contains check so that calling registerFamily with the same familyName/fullName pair more than once does not grow the family list unboundedly and slow down font lookup. Apply the fix and add a unit test to both openpdf-core-legacy and openpdf-core-modern modules, covering the deduplication invariant via a package-private getRegisteredFamily accessor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Not up to standards ⛔
|
|
Hi @asturio, This PR backports the font family duplicate-registration fix to the Heads up: the SonarCloud duplication gate is red here, but it's not a code-quality issue — this PR touches the Whenever you get a chance, I'd appreciate your review, and if it looks good, approval/merge into I'd also kindly ask, once merged, if an official release including this fix could be cut — particularly for the Java 8-compatible line (#1621), since I'd rather rely on an official release than patch it in locally. Thanks for maintaining OpenPDF! |


Description of the new Feature/Bugfix
FontFactoryImp.registerFamilyappended a[familyName, fullName]pair toits internal family list on every call, even when that exact pair was
already registered. Repeated registration of the same font grew the list
unboundedly and slowed down font lookup over time.
Guarded the insertion path with a
containscheck so the samefamilyName/fullName pair is only ever added once. Applied identically to
both the legacy (
com.lowagie) and modern (org.openpdf)FontFactoryImpcopies this branch ships, each with its own package-private
getRegisteredFamilyaccessor and unit test covering the deduplicationinvariant.
Related Issue: none (found during code review, not tied to a filed issue)
Unit-Tests for the new Feature/Bugfix
Compatibilities Issues
No behavioral change for callers -
registerFamilystill registers thepair, just without duplicating it on repeat calls. No existing method
signatures changed;
getRegisteredFamilyis a new package-privateaccessor, added only for the test, in both modules.
Your real name
Diego Garcia
Testing details
Added
FontFactoryImpTestcoverage for the dedup invariant in bothmodules. Full test suite run locally with no regressions.
🤖 Generated with Claude Code