Can't use custom font in React Native iOS.
My font family name is "Impact".
In RCTConvert.m
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family
size:(id)size weight:(id)weight style:(id)style
scaleMultiplier:(CGFloat)scaleMultiplier
UIFont *bestMatch = font;
CGFloat closestWeight = INFINITY;
for (NSString *name in [UIFont fontNamesForFamilyName:familyName]) {
UIFont *match = [UIFont fontWithName:name size:fontSize];
if (isItalic == RCTFontIsItalic(match) &&
isCondensed == RCTFontIsCondensed(match)) {
CGFloat testWeight = RCTWeightOfFont(match);
if (ABS(testWeight - fontWeight) < ABS(closestWeight - fontWeight)) {
bestMatch = match;
closestWeight = testWeight;
}
}
}
return bestMatch;
I find when I use font family "Impact", the code
isItalic == RCTFontIsItalic(match) &&
isCondensed == RCTFontIsCondensed(match)
return false so bestMatch return nil.
I also find other custom font families work fine. Just "Impact" don't.
Can't use custom font in React Native iOS.
My font family name is "Impact".
In
RCTConvert.mI find when I use font family "Impact", the code
isItalic == RCTFontIsItalic(match) && isCondensed == RCTFontIsCondensed(match)return
falsesobestMatchreturnnil.I also find other custom font families work fine. Just "Impact" don't.