Skip to content

Commit

Permalink
Fabric: Fixing an incorrect empty image placeholder for NSAttributedS…
Browse files Browse the repository at this point in the history
…tring 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
  • Loading branch information
shergin authored and facebook-github-bot committed Dec 12, 2019
1 parent aaa2765 commit 7cf43af
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex

NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedString &attributedString)
{
static UIImage *placeholderImage;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
placeholderImage = [[UIImage alloc] init];
});

NSMutableAttributedString *nsAttributedString = [[NSMutableAttributedString alloc] init];

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

NSTextAttachment *attachment = [NSTextAttachment new];
attachment.image = placeholderImage;
attachment.bounds = bounds;

nsAttributedStringFragment = [NSAttributedString attributedStringWithAttachment:attachment];
Expand Down

0 comments on commit 7cf43af

Please sign in to comment.