From d6e9891577c81503407adaa85db8f5bf97557db0 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Thu, 9 Feb 2023 10:57:50 -0800 Subject: [PATCH] Reduce log level of "unrecognized font family" from Error to Info Summary: Changelog: [iOS][Fixed] - Unrecognized fontFamily values no longer trigger a redbox ## Context We are starting to roll out a new consistent approach to style errors in React Native, where malformed or semantically invalid style values will never be treated as runtime errors. Instead, bad style values will consistently fall back to known defaults; the incorrect visual rendering will serve as the main runtime diagnostic for developers. We will advise developers to rely on static types for additional diagnostics. This work will take place over multiple commits and possibly multiple releases of React Native. ## This diff Here we fix this issue as it applies to the `fontFamily` style prop. The legacy (Paper) renderer on iOS is the only concrete implementation that had to change. Fabric and Android already implement the correct behaviour. h/t EvanBacon for the report: https://twitter.com/Baconbrix/status/1623039650775371792 Reviewed By: huntie Differential Revision: D43159284 fbshipit-source-id: 6afeef3abc5781e18671708f642073d25f2347e9 --- React/Views/RCTFont.mm | 2 +- packages/rn-tester/js/examples/Text/TextExample.android.js | 3 +++ packages/rn-tester/js/examples/Text/TextExample.ios.js | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/React/Views/RCTFont.mm b/React/Views/RCTFont.mm index e119657d3716fd..4f75304ee76a7b 100644 --- a/React/Views/RCTFont.mm +++ b/React/Views/RCTFont.mm @@ -424,7 +424,7 @@ + (UIFont *)updateFont:(UIFont *)font isCondensed = isCondensedFont(font); } else { // Not a valid font or family - RCTLogError(@"Unrecognized font family '%@'", familyName); + RCTLogInfo(@"Unrecognized font family '%@'", familyName); if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) { font = [UIFont systemFontOfSize:fontSize weight:fontWeight]; } else if (fontWeight > UIFontWeightRegular) { diff --git a/packages/rn-tester/js/examples/Text/TextExample.android.js b/packages/rn-tester/js/examples/Text/TextExample.android.js index 5f5b4a1f7f2d5a..8234bde9a39088 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.android.js +++ b/packages/rn-tester/js/examples/Text/TextExample.android.js @@ -251,6 +251,9 @@ class TextExample extends React.Component<{...}> { Monospace Bold (After 5.0) + + Unknown Font Family + diff --git a/packages/rn-tester/js/examples/Text/TextExample.ios.js b/packages/rn-tester/js/examples/Text/TextExample.ios.js index 4e1dcc84b7ce37..00e387b53c7bba 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.ios.js +++ b/packages/rn-tester/js/examples/Text/TextExample.ios.js @@ -639,6 +639,9 @@ exports.examples = [ }}> Verdana bold + + Unknown Font Family + ); },