[jira] [Commented] (WEEX-496) In CoreText mode, origin of first line is incorret under iOS9 or lower
[ https://issues.apache.org/jira/browse/WEEX-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16642761#comment-16642761 ] ASF GitHub Bot commented on WEEX-496: - Hanks10100 closed pull request #1319: [WEEX-496][iOS] In CoreText mode, origin of first line is incorret un… URL: https://github.com/apache/incubator-weex/pull/1319 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.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m index 3dcc827d07..d714b87abb 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m @@ -124,6 +124,8 @@ @implementation WXTextComponent NSString *_textOverflow; CGFloat _lineHeight; CGFloat _letterSpacing; +CGFloat _fontDescender; +CGFloat _fontAscender; BOOL _truncationLine; // support trunk tail NSAttributedString * _ctAttributedString; @@ -430,6 +432,9 @@ - (NSMutableAttributedString *)buildCTAttributeString CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)font.fontName, font.pointSize, NULL); +_fontAscender = font.ascender; +_fontDescender = font.descender; + if (ctFont) { [attributedString addAttribute:(id)kCTFontAttributeName value:(__bridge id)(ctFont) range:NSMakeRange(0, string.length)]; CFRelease(ctFont); @@ -720,6 +725,15 @@ - (void)drawTextWithContext:(CGContextRef)context bounds:(CGRect)bounds padding: BOOL needTruncation = NO; CTLineRef ctTruncatedLine = NULL; CTFrameGetLineOrigins(_coreTextFrameRef, CFRangeMake(0, 0), lineOrigins); + +CGFloat fixDescent = 0; +if (lineCount > 0 && _lineHeight && WX_SYS_VERSION_LESS_THAN(@"10.0")) { +CGFloat ascent, descent, leading; +CTLineRef line1 = (CTLineRef)CFArrayGetValueAtIndex(ctLines, 0); +CTLineGetTypographicBounds(line1, , , ); +fixDescent = (descent + _fontDescender) + (ascent - _fontAscender); +} + for (CFIndex lineIndex = 0;(!_lines || _lines > lineIndex) && lineIndex < lineCount; lineIndex ++) { CTLineRef lineRef = NULL; lineRef = CFArrayGetValueAtIndex(ctLines, lineIndex); @@ -728,7 +742,7 @@ - (void)drawTextWithContext:(CGContextRef)context bounds:(CGRect)bounds padding: } CGPoint lineOrigin = lineOrigins[lineIndex]; lineOrigin.x += padding.left; -lineOrigin.y -= padding.top; +lineOrigin.y -= padding.top + fixDescent; CFArrayRef runs = CTLineGetGlyphRuns(lineRef); [mutableLines addObject:(__bridge id _Nonnull)(lineRef)]; // lineIndex base 0 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: us...@infra.apache.org > In CoreText mode, origin of first line is incorret under iOS9 or lower > -- > > Key: WEEX-496 > URL: https://issues.apache.org/jira/browse/WEEX-496 > Project: Weex > Issue Type: Bug > Components: iOS >Affects Versions: 0.19 >Reporter: Wang Qianyuan >Assignee: xingZhang >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (WEEX-496) In CoreText mode, origin of first line is incorret under iOS9 or lower
[ https://issues.apache.org/jira/browse/WEEX-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16540022#comment-16540022 ] ASF GitHub Bot commented on WEEX-496: - Github user weex-bot commented on the issue: https://github.com/apache/incubator-weex/pull/1319 Messages :book: has no jsfm file changed. :book: jsfm test finished. Generated by :no_entry_sign: http://github.com/danger/danger-js/;>dangerJS > In CoreText mode, origin of first line is incorret under iOS9 or lower > -- > > Key: WEEX-496 > URL: https://issues.apache.org/jira/browse/WEEX-496 > Project: Weex > Issue Type: Bug > Components: iOS >Affects Versions: 0.19 >Reporter: Wang Qianyuan >Assignee: xingZhang >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (WEEX-496) In CoreText mode, origin of first line is incorret under iOS9 or lower
[ https://issues.apache.org/jira/browse/WEEX-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16540017#comment-16540017 ] ASF GitHub Bot commented on WEEX-496: - GitHub user wqyfavor opened a pull request: https://github.com/apache/incubator-weex/pull/1319 [WEEX-496][iOS] In CoreText mode, origin of first line is incorret un… …der iOS9 or lower. First of all, thank you for your contribution! Please makes sure that these checkboxes are checked before submitting your PR, thank you! CheckList: **if** *isBugFix* **:** * [ ] Make sure that you add at least one unit test for the bug which you had fixed. **elif** *isNewFeature* **:** * [ ] Update API docs for the component. * [ ] Update/Add demo to demonstrate new feature. * [ ] Update test scripts for the feature. * [ ] Add unit tests for the feature. You can merge this pull request into a Git repository by running: $ git pull https://github.com/wqyfavor/incubator-weex fix-coretext3 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-weex/pull/1319.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1319 commit a5530ce91f51d707558cb03a2dbc230b4300b4b3 Author: 神漠 Date: 2018-07-11T11:56:59Z [WEEX-496][iOS] In CoreText mode, origin of first line is incorret under iOS9 or lower. > In CoreText mode, origin of first line is incorret under iOS9 or lower > -- > > Key: WEEX-496 > URL: https://issues.apache.org/jira/browse/WEEX-496 > Project: Weex > Issue Type: Bug > Components: iOS >Affects Versions: 0.19 >Reporter: Wang Qianyuan >Assignee: xingZhang >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (WEEX-496) In CoreText mode, origin of first line is incorret under iOS9 or lower
[ https://issues.apache.org/jira/browse/WEEX-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16536508#comment-16536508 ] ASF GitHub Bot commented on WEEX-496: - Github user asfgit closed the pull request at: https://github.com/apache/incubator-weex/pull/1312 > In CoreText mode, origin of first line is incorret under iOS9 or lower > -- > > Key: WEEX-496 > URL: https://issues.apache.org/jira/browse/WEEX-496 > Project: Weex > Issue Type: Bug > Components: iOS >Affects Versions: 0.19 >Reporter: Wang Qianyuan >Assignee: xingZhang >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (WEEX-496) In CoreText mode, origin of first line is incorret under iOS9 or lower
[ https://issues.apache.org/jira/browse/WEEX-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16536040#comment-16536040 ] ASF GitHub Bot commented on WEEX-496: - Github user weex-bot commented on the issue: https://github.com/apache/incubator-weex/pull/1312 Warnings :warning: No Changelog changes! Messages :book: danger test finished. Generated by :no_entry_sign: http://github.com/danger/danger-js/;>dangerJS > In CoreText mode, origin of first line is incorret under iOS9 or lower > -- > > Key: WEEX-496 > URL: https://issues.apache.org/jira/browse/WEEX-496 > Project: Weex > Issue Type: Bug > Components: iOS >Affects Versions: 0.19 >Reporter: Wang Qianyuan >Assignee: xingZhang >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (WEEX-496) In CoreText mode, origin of first line is incorret under iOS9 or lower
[ https://issues.apache.org/jira/browse/WEEX-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16536037#comment-16536037 ] ASF GitHub Bot commented on WEEX-496: - GitHub user wqyfavor opened a pull request: https://github.com/apache/incubator-weex/pull/1312 [WEEX-496][iOS] In CoreText mode, origin of first line is incorret un… …der iOS9 or lower. First of all, thank you for your contribution! Please makes sure that these checkboxes are checked before submitting your PR, thank you! CheckList: **if** *isBugFix* **:** * [ ] Make sure that you add at least one unit test for the bug which you had fixed. **elif** *isNewFeature* **:** * [ ] Update API docs for the component. * [ ] Update/Add demo to demonstrate new feature. * [ ] Update test scripts for the feature. * [ ] Add unit tests for the feature. You can merge this pull request into a Git repository by running: $ git pull https://github.com/wqyfavor/incubator-weex fix-coretext2 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-weex/pull/1312.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1312 commit 402feabd796476d9d95d515a4919d0dae10407ff Author: 神漠 Date: 2018-07-08T09:05:09Z [WEEX-496][iOS] In CoreText mode, origin of first line is incorret under iOS9 or lower. > In CoreText mode, origin of first line is incorret under iOS9 or lower > -- > > Key: WEEX-496 > URL: https://issues.apache.org/jira/browse/WEEX-496 > Project: Weex > Issue Type: Bug > Components: iOS >Affects Versions: 0.19 >Reporter: Wang Qianyuan >Assignee: xingZhang >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)