You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/05/02 09:31:38 UTC

[1/3] incubator-weex git commit: * [ios] fix text height below iOS 10

Repository: incubator-weex
Updated Branches:
  refs/heads/0.13-dev 30cc18d8c -> 50f6f8fd1


* [ios] fix text height below iOS 10


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

Branch: refs/heads/0.13-dev
Commit: 83c8208c8f6e59ce95a9f540be93d42bc61db48a
Parents: 30cc18d
Author: acton393 <zh...@gmail.com>
Authored: Tue May 2 16:33:34 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue May 2 16:33:34 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83c8208c/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 56c158a..61d94e5 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -149,10 +149,6 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
 
 - (BOOL)useCoreText
 {
-    if (WX_SYS_VERSION_LESS_THAN(@"10.0")) {
-        // there is something wrong with coreText drawing lineHeight, trying to fix this, or anyone who can help me to fix this.
-        return NO;
-    }
     
     if ([_useCoreTextAttr isEqualToString:@"yes"]) {
         return YES;
@@ -372,6 +368,7 @@ do {\
                                            NULL);
     if (ctFont) {
         [attributedString addAttribute:(id)kCTFontAttributeName value:(__bridge id)(ctFont) range:NSMakeRange(0, string.length)];
+        CFRelease(ctFont);
     }
     
     if(_textDecoration == WXTextDecorationUnderline){
@@ -416,8 +413,6 @@ do {\
         }
     }
     
-    CFRelease(ctFont);
-    
     return attributedString;
 }
 
@@ -485,6 +480,9 @@ do {\
 
 - (BOOL)adjustLineHeight
 {
+    if (WX_SYS_VERSION_LESS_THAN(@"10.0")) {
+        return true;
+    }
     return ![self useCoreText];
 }
 
@@ -627,7 +625,6 @@ do {\
             CGPoint lineOrigin = lineOrigins[lineIndex];
             lineOrigin.x += padding.left;
             lineOrigin.y -= padding.top;
-            CGContextSetTextPosition(context, lineOrigin.x, lineOrigin.y);
             CFArrayRef runs = CTLineGetGlyphRuns(lineRef);
             [mutableLines addObject:(__bridge id _Nonnull)(lineRef)];
             // lineIndex base 0
@@ -652,6 +649,7 @@ do {\
             }
             
             if (needTruncation) {
+                CGContextSetTextPosition(context, lineOrigin.x, lineOrigin.y);
                 ctTruncatedLine = [self buildTruncatedLineWithRuns:runs lines:mutableLines path:cgPath];
                 if (ctTruncatedLine) {
                     CFArrayRef truncatedRuns = CTLineGetGlyphRuns(ctTruncatedLine);
@@ -679,9 +677,14 @@ do {\
     for (CFIndex runIndex = 0; runIndex < CFArrayGetCount(runs); runIndex ++) {
         CTRunRef run = NULL;
         run = CFArrayGetValueAtIndex(runs, runIndex);
-        CTRunDraw(run, context, CFRangeMake(0, 0));
         CFDictionaryRef attr = NULL;
         attr = CTRunGetAttributes(run);
+        NSNumber *baselineOffset = (NSNumber*)CFDictionaryGetValue(attr, NSBaselineOffsetAttributeName);
+        if (baselineOffset) {
+            lineOrigin.y += [baselineOffset doubleValue];
+        }
+        CGContextSetTextPosition(context, lineOrigin.x, lineOrigin.y);
+        CTRunDraw(run, context, CFRangeMake(0, 0));
         CFIndex glyphCount = CTRunGetGlyphCount(run);
         if (glyphCount <= 0) continue;
         
@@ -830,6 +833,13 @@ do {\
     totalHeight = totalHeight + actualLineCount * leading;
     CFRelease(frameRef);
     
+    if (WX_SYS_VERSION_LESS_THAN(@"10.0")) {
+        if(actualLineCount && actualLineCount < lineCount) {
+            suggestSize.height = suggestSize.height * actualLineCount / lineCount;
+        }
+        return suggestSize;
+    }
+    
     return CGSizeMake(suggestSize.width, totalHeight);
 }
 


[3/3] incubator-weex git commit: * [ios] fix attribute for useCoreText

Posted by cx...@apache.org.
* [ios] fix attribute for useCoreText


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

Branch: refs/heads/0.13-dev
Commit: 50f6f8fd1b3b4a100ec718f476921360daa5d69b
Parents: 601b6e4
Author: acton393 <zh...@gmail.com>
Authored: Tue May 2 16:42:59 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue May 2 16:42:59 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/50f6f8fd/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 c2fb5da..eb96157 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -150,7 +150,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
 - (BOOL)useCoreText
 {
     
-    if ([_useCoreTextAttr isEqualToString:@"yes"]) {
+    if ([_useCoreTextAttr isEqualToString:@"true"]) {
         return YES;
     }
     if ([_useCoreTextAttr isEqualToString:@"false"]) {


[2/3] incubator-weex git commit: * [ios] add comment for modifications

Posted by cx...@apache.org.
* [ios] add comment for modifications


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

Branch: refs/heads/0.13-dev
Commit: 601b6e428c49c9e7bdcba9e0746409600287111a
Parents: 83c8208
Author: acton393 <zh...@gmail.com>
Authored: Tue May 2 16:36:57 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue May 2 16:36:57 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/601b6e42/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 61d94e5..c2fb5da 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -834,6 +834,7 @@ do {\
     CFRelease(frameRef);
     
     if (WX_SYS_VERSION_LESS_THAN(@"10.0")) {
+        // there is something wrong with coreText drawing text height, trying to fix this with more efficent way.
         if(actualLineCount && actualLineCount < lineCount) {
             suggestSize.height = suggestSize.height * actualLineCount / lineCount;
         }