From c712d35984d4bad2d515a2852953af17d804ffe5 Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Mon, 19 Aug 2024 12:16:04 +0700 Subject: [PATCH] chore(ios): adjustments per review --- .../KeymanEngine/Classes/Resource Data/FontManager.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/engine/KMEI/KeymanEngine/Classes/Resource Data/FontManager.swift b/ios/engine/KMEI/KeymanEngine/Classes/Resource Data/FontManager.swift index 9f0047d7f7b..6070de2c96f 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/Resource Data/FontManager.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/Resource Data/FontManager.swift @@ -56,10 +56,15 @@ public class FontManager { /** * Iterates across all listed fonts, registering those not yet registered. * Checks for, and filters out, any fonts already registered on the system. + * Also initializes the registration cache per URL if needed. */ private func registerListedFonts(_ initialFontSet: Set) { // If we are unable to read the font file's properties sufficiently, - // skip it. We also don't need to register anything already registered. + // skip it. We also don't need to register anything already registered or + // that cannot be registered due to loading/parsing errors. + // + // Calls to `cachedFont` after the `.filter` below may be assumed to have + // non-nil return values. var fontSet = initialFontSet.filter { !(cachedFont(at: $0)?.isRegistered ?? true) } // The prior line filters out any entries where cachedFont(at: $0) would be nil. @@ -195,7 +200,6 @@ public class FontManager { * Only fonts that could not be found will be returned within the result set. */ private func missingFonts(from fontNames: Set) -> Set { - // Arrays are treated 'by value'; it's already a shallow copy. var fontsToFind = fontNames UIFont.familyNames.forEach { familyName in