weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acton...@apache.org
Subject [1/8] incubator-weex git commit: * [ios] support rtl text direction
Date Thu, 07 Sep 2017 09:27:51 GMT
Repository: incubator-weex
Updated Branches:
  refs/heads/0.16-dev 254bc45ef -> aeb601eb8


* [ios] support rtl text direction


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5307a2b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5307a2b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5307a2b1

Branch: refs/heads/0.16-dev
Commit: 5307a2b1f04c2279d5f5a806fb642c9b13ef8187
Parents: 1227b69
Author: acton393 <zhangxing610321@gmail.com>
Authored: Mon Sep 4 20:44:40 2017 +0800
Committer: acton393 <zhangxing610321@gmail.com>
Committed: Mon Sep 4 20:44:40 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5307a2b1/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index 664b0e8..e7e118a 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -124,6 +124,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
     CGFloat _lineHeight;
     CGFloat _letterSpacing;
     BOOL _truncationLine; // support trunk tail
+    NSString * _writeDirection;
     
     BOOL _needsRemoveObserver;
     NSAttributedString * _ctAttributedString;
@@ -253,6 +254,9 @@ do {\
         [self setNeedsRepaint];
         [self setNeedsLayout];
     }
+    if (attributes[@"dir"]) {
+        _writeDirection = [[WXConvert NSString:attributes[@"dir"]] lowercaseString];
+    }
 }
 
 - (void)setNeedsRepaint
@@ -393,6 +397,11 @@ do {\
         [attributedString addAttribute:NSForegroundColorAttributeName value:_color range:NSMakeRange(0,
string.length)];
     }
     
+    if ([[_writeDirection lowercaseString] isEqualToString:@"rtl"])
+    {
+        [attributedString addAttribute:(id)kCTWritingDirectionAttributeName value:@[@(kCTWritingDirectionRightToLeft|kCTWritingDirectionEmbedding)]
range:NSMakeRange(0, string.length)];
+    }
+    
     if (_fontFamily) {
         NSString * keyPath = [NSString stringWithFormat:@"%@.tempSrc", _fontFamily];
         NSString * fontSrc = [[[WXRuleManager sharedInstance] getRule:@"fontFace"] valueForKeyPath:keyPath];
@@ -471,6 +480,10 @@ do {\
     if(_color) {
         [attributedString addAttribute:NSForegroundColorAttributeName value:_color range:NSMakeRange(0,
string.length)];
     }
+    if ([[_writeDirection lowercaseString] isEqualToString:@"rtl"])
+    {
+        [attributedString addAttribute:NSWritingDirectionAttributeName value:@[@(1)] range:NSMakeRange(0,
string.length)];
+    }
     
     if (_fontFamily) {
         NSString * keyPath = [NSString stringWithFormat:@"%@.tempSrc", _fontFamily];


Mime
View raw message