You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/17 05:49:15 UTC
[11/50] [abbrv] incubator-weex git commit: * [ios] default use textkit
* [ios] default use textkit
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/dc3e708b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/dc3e708b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/dc3e708b
Branch: refs/heads/dev
Commit: dc3e708b97bd763d8ee40706ed09cbc7402f3199
Parents: 6cca6f8
Author: acton393 <zh...@gmail.com>
Authored: Thu Apr 13 14:48:50 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Apr 13 14:48:50 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc3e708b/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 9df7fef..a379c87 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -131,7 +131,7 @@ static BOOL textRenderUsingCoreText;
if ([attributes objectForKey:@"coretext"]) {
_coretext = [WXConvert BOOL:attributes[@"coretext"]];
} else {
- _coretext = YES;
+ _coretext = NO;
}
BOOL renderUsingCoreText = YES;
if (weexInstance.userInfo[@"renderUsingCoreText"]) {
@@ -265,8 +265,9 @@ do {\
__weak typeof(self) weakSelf = self;
return ^CGSize (CGSize constrainedSize) {
CGSize computedSize = CGSizeZero;
- NSTextStorage *textStorage = [weakSelf textStorageWithWidth:constrainedSize.width];
+ NSTextStorage *textStorage = nil;
if (!(weakSelf.coretext && [WXTextComponent textRenderUsingCoreText]) ) {
+ textStorage = [weakSelf textStorageWithWidth:constrainedSize.width];
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
computedSize = [layoutManager usedRectForTextContainer:textContainer].size;
@@ -290,7 +291,7 @@ do {\
if (!isnan(weakSelf.cssNode->style.maxDimensions[CSS_HEIGHT])) {
computedSize.height = MIN(computedSize.height, weakSelf.cssNode->style.maxDimensions[CSS_HEIGHT]);
}
- if ([WXUtility isBlankString:textStorage.string]) {
+ if (textStorage && [WXUtility isBlankString:textStorage.string]) {
// if the text value is empty or nil, then set the height is 0.
computedSize.height = 0;
}
@@ -549,7 +550,7 @@ do {\
[self _resetNativeBorderRadius];
});
}
- if (![WXTextComponent textRenderUsingCoreText] || !self.coretext) {
+ if (![self useCoreText]) {
NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
@@ -629,7 +630,8 @@ do {\
CGSize suggestSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetterRef, CFRangeMake(0, attributedStringCpy.length), NULL, CGSizeMake(aWidth, MAXFLOAT), NULL);
CGMutablePathRef path = CGPathCreateMutable();
- CGPathAddRect(path, NULL, CGRectMake(0, 0, aWidth, suggestSize.height*10));
+ // sufficient height to draw text
+ CGPathAddRect(path, NULL, CGRectMake(0, 0, aWidth, suggestSize.height * 10));
CTFrameRef frameRef = CTFramesetterCreateFrame(framesetterRef, CFRangeMake(0, attributedStringCpy.length), path, NULL);