Skip to content

Commit 6e9a46a

Browse files
generatedunixname537391475639613facebook-github-bot
authored andcommitted
xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm (#53931)
Summary: Pull Request resolved: #53931 Reviewed By: javache Differential Revision: D83144241 fbshipit-source-id: 115f085974ca6cc13c1412ab59881e4f819b594b
1 parent f599e2a commit 6e9a46a

File tree

1 file changed

+11
-10
lines changed
  • packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager

1 file changed

+11
-10
lines changed

packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <react/renderer/textlayoutmanager/RCTFontUtils.h>
1515
#include <react/renderer/textlayoutmanager/RCTTextPrimitivesConversions.h>
1616
#include <react/utils/ManagedObjectWrapper.h>
17+
#include <array>
1718

1819
using namespace facebook::react;
1920

@@ -22,16 +23,16 @@ inline static UIFontWeight RCTUIFontWeightFromInteger(NSInteger fontWeight)
2223
assert(fontWeight > 50);
2324
assert(fontWeight < 950);
2425

25-
static UIFontWeight weights[] = {
26-
/* ~100 */ UIFontWeightUltraLight,
27-
/* ~200 */ UIFontWeightThin,
28-
/* ~300 */ UIFontWeightLight,
29-
/* ~400 */ UIFontWeightRegular,
30-
/* ~500 */ UIFontWeightMedium,
31-
/* ~600 */ UIFontWeightSemibold,
32-
/* ~700 */ UIFontWeightBold,
33-
/* ~800 */ UIFontWeightHeavy,
34-
/* ~900 */ UIFontWeightBlack};
26+
static auto weights = std::to_array<UIFontWeight>(
27+
{/* ~100 */ UIFontWeightUltraLight,
28+
/* ~200 */ UIFontWeightThin,
29+
/* ~300 */ UIFontWeightLight,
30+
/* ~400 */ UIFontWeightRegular,
31+
/* ~500 */ UIFontWeightMedium,
32+
/* ~600 */ UIFontWeightSemibold,
33+
/* ~700 */ UIFontWeightBold,
34+
/* ~800 */ UIFontWeightHeavy,
35+
/* ~900 */ UIFontWeightBlack});
3536
// The expression is designed to convert something like 760 or 830 to 7.
3637
return weights[(fontWeight + 50) / 100 - 1];
3738
}

0 commit comments

Comments
 (0)