Skip to content

Commit 7cf43af

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Fixing an incorrect empty image placeholder for NSAttributedString attachment
Summary: Same as D18048277 but for Fabric text infra. Changelog: [Internal] Fabric-specific internal change. Reviewed By: PeteTheHeat Differential Revision: D18950415 fbshipit-source-id: 09701e261ecb871b3624260a36dd607fdb70e717
1 parent aaa2765 commit 7cf43af

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm

+7
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
217217

218218
NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedString &attributedString)
219219
{
220+
static UIImage *placeholderImage;
221+
static dispatch_once_t onceToken;
222+
dispatch_once(&onceToken, ^{
223+
placeholderImage = [[UIImage alloc] init];
224+
});
225+
220226
NSMutableAttributedString *nsAttributedString = [[NSMutableAttributedString alloc] init];
221227

222228
[nsAttributedString beginEditing];
@@ -230,6 +236,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
230236
.size = {.width = layoutMetrics.frame.size.width, .height = layoutMetrics.frame.size.height}};
231237

232238
NSTextAttachment *attachment = [NSTextAttachment new];
239+
attachment.image = placeholderImage;
233240
attachment.bounds = bounds;
234241

235242
nsAttributedStringFragment = [NSAttributedString attributedStringWithAttachment:attachment];

0 commit comments

Comments
 (0)