Skip to content

Commit 5683932

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Fix NSInvalidArgumentException for Invalid Font Family Name
Summary: We observed that in certain production scenarios, `[UIFont fontNamesForFamilyName:familyName]` returns `nil`. This is problematic because we cannot insert `nil` (which is not an object type) into `NSCache`. Currently, this is causing `NSInvalidArgumentException` to be thrown. This fix works around the problem by guarding against `nil`. Changelog: [iOS][Fixed] - Fix NSInvalidArgumentException for invalid font family names. Reviewed By: fkgozali Differential Revision: D31011394 fbshipit-source-id: a9eb9ce69efd832acca65787c665fcbb7b42a795
1 parent b0c8a4e commit 5683932

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

React/Views/RCTFont.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ struct __attribute__((__packed__)) CacheKey {
172172

173173
auto names = [cache objectForKey:familyName];
174174
if (!names) {
175-
names = [UIFont fontNamesForFamilyName:familyName];
175+
names = [UIFont fontNamesForFamilyName:familyName] ?: [NSArray new];
176176
[cache setObject:names forKey:familyName];
177177
}
178178
return names;

0 commit comments

Comments
 (0)