Skip to content

Commit

Permalink
Fixes facebook#813
Browse files Browse the repository at this point in the history
Also fix RCTShadowText export name.
  • Loading branch information
drkibitz committed Apr 15, 2015
1 parent bac60f5 commit 1edc79c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Libraries/Text/RCTShadowText.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ static css_dim_t RCTMeasure(void *context, float width)
RCTShadowText *shadowText = (__bridge RCTShadowText *)context;

NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:[shadowText attributedString]];
NSTextStorage *previousTextStorage = shadowText.layoutManager.textStorage;
if (previousTextStorage) {
[previousTextStorage removeLayoutManager:shadowText.layoutManager];
}
[textStorage addLayoutManager:shadowText.layoutManager];

shadowText.textContainer.size = CGSizeMake(isnan(width) ? CGFLOAT_MAX : width, CGFLOAT_MAX);
shadowText.layoutManager.textStorage = textStorage;
[shadowText.layoutManager ensureLayoutForTextContainer:shadowText.textContainer];

CGSize computedSize = [shadowText.layoutManager usedRectForTextContainer:shadowText.textContainer].size;

[textStorage removeLayoutManager:shadowText.layoutManager];
if (previousTextStorage) {
[previousTextStorage addLayoutManager:shadowText.layoutManager];
}

css_dim_t result;
result.dimensions[CSS_WIDTH] = RCTCeilPixelValue(computedSize.width);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Text/RCTTextManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (RCTShadowView *)shadowView
RCT_EXPORT_SHADOW_PROPERTY(fontStyle, NSString)
RCT_EXPORT_SHADOW_PROPERTY(isHighlighted, BOOL)
RCT_EXPORT_SHADOW_PROPERTY(lineHeight, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(maxNumberOfLines, NSInteger)
RCT_EXPORT_SHADOW_PROPERTY(maximumNumberOfLines, NSInteger)
RCT_EXPORT_SHADOW_PROPERTY(shadowOffset, CGSize)
RCT_EXPORT_SHADOW_PROPERTY(textAlign, NSTextAlignment)
RCT_REMAP_SHADOW_PROPERTY(backgroundColor, textBackgroundColor, UIColor)
Expand Down

0 comments on commit 1edc79c

Please sign in to comment.