[
https://issues.apache.org/jira/browse/WEEX-446?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16696424#comment-16696424
]
ASF GitHub Bot commented on WEEX-446:
-------------------------------------
wqyfavor closed pull request #1289: [WEEX-446,447][iOS] Fix core text layout
bug.
URL: https://github.com/apache/incubator-weex/pull/1289
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm
b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm
index 13f470a253..714b2edd45 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm
@@ -971,9 +971,19 @@ - (CGSize)calculateTextHeightWithWidth:(CGFloat)aWidth
aWidth = CGFLOAT_MAX;
}
aWidth = [attributedStringCpy boundingRectWithSize:CGSizeMake(aWidth,
CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading
context:nil].size.width;
+
+ /* Must get ceil of aWidth. Or core text may not return correct bounds.
+ Maybe aWidth without ceiling triggered some critical conditions. */
+ aWidth = ceil(aWidth);
CTFramesetterRef ctframesetterRef =
CTFramesetterCreateWithAttributedString((__bridge
CFAttributedStringRef)(attributedStringCpy));
suggestSize =
CTFramesetterSuggestFrameSizeWithConstraints(ctframesetterRef, CFRangeMake(0,
0), NULL, CGSizeMake(aWidth, MAXFLOAT), NULL);
+ if (_lines == 0) {
+ // If not line limit use suggestSize directly.
+ CFRelease(ctframesetterRef);
+ return CGSizeMake(aWidth, suggestSize.height);
+ }
+
CGMutablePathRef path = NULL;
path = CGPathCreateMutable();
// sufficient height to draw text
@@ -982,15 +992,14 @@ - (CGSize)calculateTextHeightWithWidth:(CGFloat)aWidth
CTFrameRef frameRef = NULL;
frameRef = CTFramesetterCreateFrame(ctframesetterRef, CFRangeMake(0,
attributedStringCpy.length), path, NULL);
CGPathRelease(path);
+ CFRelease(ctframesetterRef);
- CFArrayRef lines = NULL;
if (NULL == frameRef) {
//try to protect unexpected crash.
return suggestSize;
}
- CFRelease(ctframesetterRef);
- ctframesetterRef = NULL;
- lines = CTFrameGetLines(frameRef);
+
+ CFArrayRef lines = CTFrameGetLines(frameRef);
CFIndex lineCount = CFArrayGetCount(lines);
CGFloat ascent = 0;
CGFloat descent = 0;
@@ -1010,7 +1019,6 @@ - (CGSize)calculateTextHeightWithWidth:(CGFloat)aWidth
totalHeight = totalHeight + actualLineCount * leading;
CFRelease(frameRef);
- frameRef = NULL;
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.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> <text>组件在某情况下文字显示不全
> -------------------
>
> Key: WEEX-446
> URL: https://issues.apache.org/jira/browse/WEEX-446
> Project: Weex
> Issue Type: Bug
> Components: iOS
> Affects Versions: 0.18
> Environment: iOS iphone6 11.3
> Reporter: huangnao
> Assignee: acton393
> Priority: Major
> Attachments: [email protected]
>
>
> <text>组件在某情况下文字显示不全,demo如下:
> [http://dotwe.org/vue/7f9b97dfe8795cd09d44dcb27066153a]
> dotwe上看是没有问题的,请用iOS的weex playground查看。android未测试。
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)