mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Add font variant support (#44112)
Summary: Fixes https://github.com/facebook/react-native/issues/44064 ## Changelog: [IOS] [FIXED] - [iOS] Fabric: Add font variant support Pull Request resolved: https://github.com/facebook/react-native/pull/44112 Test Plan: Demo in https://github.com/facebook/react-native/issues/44064 . Reviewed By: cortinico Differential Revision: D56189145 Pulled By: cipolleschi fbshipit-source-id: a814cf4959b0160e36f79eaf6c7dcbffe5ef60c5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8a343c6256
commit
89eb794751
+47
-2
@@ -6,10 +6,12 @@
|
||||
*/
|
||||
|
||||
#import "RCTFontUtils.h"
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
#import <algorithm>
|
||||
#import <cmath>
|
||||
#import <limits>
|
||||
#import <map>
|
||||
#import <mutex>
|
||||
|
||||
static RCTFontProperties RCTDefaultFontProperties()
|
||||
@@ -62,8 +64,51 @@ static RCTFontStyle RCTGetFontStyle(UIFont *font)
|
||||
|
||||
static NSArray *RCTFontFeatures(RCTFontVariant fontVariant)
|
||||
{
|
||||
// FIXME:
|
||||
return @[];
|
||||
NSMutableArray *fontFeatures = [NSMutableArray array];
|
||||
static std::map<RCTFontVariant, NSDictionary *> mapping;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
mapping = {
|
||||
{RCTFontVariantSmallCaps, @{
|
||||
UIFontFeatureTypeIdentifierKey : @(kLowerCaseType),
|
||||
UIFontFeatureSelectorIdentifierKey : @(kLowerCaseSmallCapsSelector),
|
||||
}},
|
||||
{RCTFontVariantOldstyleNums, @{
|
||||
UIFontFeatureTypeIdentifierKey : @(kNumberCaseType),
|
||||
UIFontFeatureSelectorIdentifierKey : @(kLowerCaseNumbersSelector),
|
||||
}},
|
||||
{RCTFontVariantLiningNums, @{
|
||||
UIFontFeatureTypeIdentifierKey : @(kNumberCaseType),
|
||||
UIFontFeatureSelectorIdentifierKey : @(kUpperCaseNumbersSelector),
|
||||
}},
|
||||
{RCTFontVariantTabularNums, @{
|
||||
UIFontFeatureTypeIdentifierKey : @(kNumberSpacingType),
|
||||
UIFontFeatureSelectorIdentifierKey : @(kMonospacedNumbersSelector),
|
||||
}},
|
||||
{RCTFontVariantProportionalNums, @{
|
||||
UIFontFeatureTypeIdentifierKey : @(kNumberSpacingType),
|
||||
UIFontFeatureSelectorIdentifierKey : @(kProportionalNumbersSelector),
|
||||
}},
|
||||
};
|
||||
});
|
||||
|
||||
if (fontVariant & RCTFontVariantSmallCaps) {
|
||||
[fontFeatures addObject:mapping[RCTFontVariantSmallCaps]];
|
||||
}
|
||||
if (fontVariant & RCTFontVariantOldstyleNums) {
|
||||
[fontFeatures addObject:mapping[RCTFontVariantOldstyleNums]];
|
||||
}
|
||||
if (fontVariant & RCTFontVariantLiningNums) {
|
||||
[fontFeatures addObject:mapping[RCTFontVariantLiningNums]];
|
||||
}
|
||||
if (fontVariant & RCTFontVariantTabularNums) {
|
||||
[fontFeatures addObject:mapping[RCTFontVariantTabularNums]];
|
||||
}
|
||||
if (fontVariant & RCTFontVariantProportionalNums) {
|
||||
[fontFeatures addObject:mapping[RCTFontVariantProportionalNums]];
|
||||
}
|
||||
|
||||
return fontFeatures;
|
||||
}
|
||||
|
||||
static UIFont *RCTDefaultFontWithFontProperties(RCTFontProperties fontProperties)
|
||||
|
||||
Reference in New Issue
Block a user