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/04/13 11:20:59 UTC
[09/23] incubator-weex git commit: * [ios] config replacement
* [ios] config replacement
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/09d8869e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/09d8869e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/09d8869e
Branch: refs/heads/0.12-dev
Commit: 09d8869e2d1124591ec33cfcf0a776d3a13642d2
Parents: 7eefcfb
Author: acton393 <zh...@gmail.com>
Authored: Tue Apr 11 16:09:16 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue Apr 11 16:09:16 2017 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Component/WXTextComponent.m | 25 ++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/09d8869e/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 e9cc83f..2a81b9e 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -90,6 +90,8 @@
@end
+static BOOL textRenderUsingCoreText;
+
@interface WXTextComponent()
@property (nonatomic, assign)BOOL coretext;
@end
@@ -114,6 +116,16 @@
CGFloat _lineHeight;
}
++ (void)setRenderUsingCoreText:(BOOL)usingCoreText
+{
+ textRenderUsingCoreText = usingCoreText;
+}
+
++ (BOOL)textRenderUsingCoreText
+{
+ return textRenderUsingCoreText;
+}
+
- (instancetype)initWithRef:(NSString *)ref
type:(NSString *)type
styles:(NSDictionary *)styles
@@ -123,11 +135,18 @@
{
self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance];
if (self) {
+ // just for coretext and textkit render replacement
if (attributes[@"coretext"]) {
_coretext = [WXConvert BOOL:attributes[@"coretext"]];
} else {
_coretext = YES;
}
+ BOOL renderUsingCoreText = YES;
+ if (weexInstance.userInfo[@"renderUsingCoreText"]) {
+ renderUsingCoreText = [weexInstance.userInfo[@"renderUsingCoreText"] boolValue];
+ }
+ [WXTextComponent setRenderUsingCoreText:renderUsingCoreText];
+
[self fillCSSStyles:styles];
[self fillAttributes:attributes];
}
@@ -333,6 +352,8 @@ do {\
[attributedString addAttribute:(id)kCTFontAttributeName value:(__bridge id)(ctFont) range:NSMakeRange(0, string.length)];
}
+ CFRelease(ctFont);
+
if(_textDecoration == WXTextDecorationUnderline){
[attributedString addAttribute:(id)kCTUnderlineStyleAttributeName value:@(kCTUnderlinePatternSolid | kCTUnderlineStyleSingle) range:NSMakeRange(0, string.length)];
} else if(_textDecoration == WXTextDecorationLineThrough){
@@ -438,7 +459,7 @@ do {\
- (BOOL)adjustLineHeight
{
- return !_coretext;
+ return !(_coretext && [WXTextComponent textRenderUsingCoreText]);
}
- (NSTextStorage *)textStorageWithWidth:(CGFloat)width
@@ -528,7 +549,7 @@ do {\
[self _resetNativeBorderRadius];
});
}
- if (!self.coretext) {
+ if (![WXTextComponent textRenderUsingCoreText] || !self.coretext) {
NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;