Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -756,4 +756,4 @@ - (SubmitBehavior)getSubmitBehavior
Class<RCTComponentViewProtocol> RCTTextInputCls(void)
{
return RCTTextInputComponentView.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
return effectiveBackgroundColor ?: [UIColor clearColor];
}

NSDictionary<NSAttributedStringKey, id> *RCTDefaultTextAttributes() {
static NSDictionary<NSAttributedStringKey, id> *defaultAttributes;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
defaultAttributes = @{
NSFontAttributeName : [UIFont systemFontOfSize:14.0f],
NSForegroundColorAttributeName : [UIColor blackColor],
NSBackgroundColorAttributeName : [UIColor clearColor],
NSParagraphStyleAttributeName  : [NSParagraphStyle defaultParagraphStyle],
NSShadowAttributeName : [NSShadow new],
// Add other missing attributes as needed
};
});
return defaultAttributes;
}

NSDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttributes(const TextAttributes &textAttributes)
{
NSMutableDictionary<NSAttributedStringKey, id> *attributes = [NSMutableDictionary dictionaryWithCapacity:10];
Expand Down Expand Up @@ -302,6 +318,14 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
attributes[RCTTextAttributesAccessibilityRoleAttributeName] = [NSString stringWithUTF8String:roleStr.c_str()];
}

// Apply default attributes if they're missing
NSDictionary<NSAttributedStringKey, id> *defaultAttributes = RCTDefaultTextAttributes();
for (NSAttributedStringKey key in defaultAttributes) {
if (![attributes objectForKey:key]) {
attributes[key] = defaultAttributes[key];
}
}

return [attributes copy];
}

Expand Down