@@ -30,10 +30,10 @@ @implementation RCTShadowText
3030 CGFloat _effectiveLetterSpacing;
3131}
3232
33- static css_dim_t RCTMeasure (void *context, float width, float height)
33+ static css_dim_t RCTMeasure (void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode )
3434{
3535 RCTShadowText *shadowText = (__bridge RCTShadowText *)context;
36- NSTextStorage *textStorage = [shadowText buildTextStorageForWidth: width];
36+ NSTextStorage *textStorage = [shadowText buildTextStorageForWidth: width widthMode: widthMode ];
3737 NSLayoutManager *layoutManager = textStorage.layoutManagers .firstObject ;
3838 NSTextContainer *textContainer = layoutManager.textContainers .firstObject ;
3939 CGSize computedSize = [layoutManager usedRectForTextContainer: textContainer].size ;
@@ -89,7 +89,7 @@ - (void)contentSizeMultiplierDidChange:(NSNotification *)note
8989 UIEdgeInsets padding = self.paddingAsInsets ;
9090 CGFloat width = self.frame .size .width - (padding.left + padding.right );
9191
92- NSTextStorage *textStorage = [self buildTextStorageForWidth: width];
92+ NSTextStorage *textStorage = [self buildTextStorageForWidth: width widthMode: CSS_MEASURE_MODE_EXACTLY ];
9393 [applierBlocks addObject: ^(NSDictionary <NSNumber *, RCTText *> *viewRegistry) {
9494 RCTText *view = viewRegistry[self .reactTag];
9595 view.textStorage = textStorage;
@@ -106,7 +106,7 @@ - (void)applyLayoutNode:(css_node_t *)node
106106 [self dirtyPropagation ];
107107}
108108
109- - (NSTextStorage *)buildTextStorageForWidth : (CGFloat)width
109+ - (NSTextStorage *)buildTextStorageForWidth : (CGFloat)width widthMode : ( css_measure_mode_t ) widthMode
110110{
111111 if (_cachedTextStorage && width == _cachedTextStorageWidth) {
112112 return _cachedTextStorage;
@@ -121,7 +121,7 @@ - (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width
121121 textContainer.lineFragmentPadding = 0.0 ;
122122 textContainer.lineBreakMode = _numberOfLines > 0 ? NSLineBreakByTruncatingTail : NSLineBreakByClipping;
123123 textContainer.maximumNumberOfLines = _numberOfLines;
124- textContainer.size = (CGSize){isnan (width) ? CGFLOAT_MAX : width, CGFLOAT_MAX };
124+ textContainer.size = (CGSize){widthMode == CSS_MEASURE_MODE_UNDEFINED ? CGFLOAT_MAX : width, CGFLOAT_MAX };
125125
126126 [layoutManager addTextContainer: textContainer];
127127 [layoutManager ensureLayoutForTextContainer: textContainer];
0 commit comments