[TextKit] Fix text layout issue for CJK laungages (#3026)

* [TextKit] Fix text layout issue for CJK laungages

* [ASTextKitContext] Delay filling _textStorage with attributedString until calling addLayoutManager.
This commit is contained in:
Jason Yu
2017-02-16 03:54:55 +08:00
committed by Adlai Holler
parent a6e74900c0
commit 8e18f1562c

View File

@@ -39,10 +39,18 @@
__instanceLock__ = std::make_shared<ASDN::Mutex>();
// Create the TextKit component stack with our default configuration.
_textStorage = (attributedString ? [[NSTextStorage alloc] initWithAttributedString:attributedString] : [[NSTextStorage alloc] init]);
_textStorage = [[NSTextStorage alloc] init];
_layoutManager = [[ASLayoutManager alloc] init];
_layoutManager.usesFontLeading = NO;
[_textStorage addLayoutManager:_layoutManager];
// Instead of calling [NSTextStorage initWithAttributedString:], setting attributedString just after calling addlayoutManager can fix CJK language layout issues.
// See https://github.com/facebook/AsyncDisplayKit/issues/2894
if (attributedString) {
[_textStorage setAttributedString:attributedString];
}
_textContainer = [[NSTextContainer alloc] initWithSize:constrainedSize];
// We want the text laid out up to the very edges of the container.
_textContainer.lineFragmentPadding = 0;