Skip to content

Commit

Permalink
fix(ios): fix mixed type text word order bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonelmy authored and zoomchan-cxj committed Mar 8, 2022
1 parent a81e2a3 commit 6ed4df3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ios/sdk/component/text/HippyShadowText.mm
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily

CGFloat heightOfTallestSubview = 0.0;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.text ?: @""];
NSWritingDirection direction = [[HippyI18nUtils sharedInstance] writingDirectionForCurrentAppLanguage];
if (NSWritingDirectionRightToLeft == direction) {
NSDictionary *dic = @{NSWritingDirectionAttributeName: @[@(NSWritingDirectionRightToLeft | NSWritingDirectionEmbedding)]};
[attributedString addAttributes:dic range:NSMakeRange(0, [self.text length])];
}
for (HippyShadowView *child in [self hippySubviews]) {
if ([child isKindOfClass:[HippyShadowText class]]) {
HippyShadowText *shadowText = (HippyShadowText *)child;
Expand All @@ -401,7 +406,6 @@ - (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily
[child setTextComputed];
} else {
// MTTlayout
NSWritingDirection direction = [[HippyI18nUtils sharedInstance] writingDirectionForCurrentAppLanguage];
MTTDirection nodeDirection = (NSWritingDirectionRightToLeft == direction) ? DirectionRTL : DirectionLTR;
nodeDirection = self.layoutDirection != DirectionInherit ? self.layoutDirection : nodeDirection;
MTTNodeDoLayout(child.nodeRef, NAN, NAN, nodeDirection);
Expand Down

0 comments on commit 6ed4df3

Please sign in to comment.