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:21:12 UTC

[22/23] incubator-weex git commit: * [ios] adjust configuration

* [ios] adjust configuration


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/41f524f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/41f524f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/41f524f4

Branch: refs/heads/0.12-dev
Commit: 41f524f474f7fc17d637c46166ed57910aa1683e
Parents: efd5600
Author: acton393 <zh...@gmail.com>
Authored: Thu Apr 13 18:44:38 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Apr 13 18:44:38 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h |  2 --
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 13 ++++++++-----
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.h         |  2 ++
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.m         |  9 +++++++--
 4 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/41f524f4/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h
index 7fb8f34..8b616f4 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h
@@ -22,6 +22,4 @@
 @interface WXTextComponent : WXComponent
 
 + (void)setRenderUsingCoreText:(BOOL)usingCoreText;
-+ (BOOL)useCoreText;
-
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/41f524f4/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 a6d24d9..d47e3f0 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -81,7 +81,10 @@
 @end
 
 static BOOL textRenderUsingCoreText = NO;
-static BOOL useCoreTextAttr = NO;
+
+@interface WXTextComponent()
+@property (nonatomic, assign)BOOL useCoreTextAttr;
+@end
 
 @implementation WXTextComponent
 {
@@ -124,7 +127,7 @@ static BOOL useCoreTextAttr = NO;
     if (self) {
         // just for coretext and textkit render replacement
         if ([attributes objectForKey:@"coretext"]) {
-            useCoreTextAttr = [WXConvert BOOL:attributes[@"coretext"]];
+            _useCoreTextAttr = [WXConvert BOOL:attributes[@"coretext"]];
         } else {
             _useCoreTextAttr = NO;
         }
@@ -136,9 +139,9 @@ static BOOL useCoreTextAttr = NO;
     return self;
 }
 
-+ (BOOL)useCoreText
+- (BOOL)useCoreText
 {
-    if (useCoreTextAttr) {
+    if (_useCoreTextAttr) {
         return YES;
     }
     if ([WXTextComponent textRenderUsingCoreText]) {
@@ -339,7 +342,7 @@ do {\
     }
     
     // set font
-    UIFont *font = [WXUtility fontWithSize:_fontSize textWeight:_fontWeight textStyle:_fontStyle fontFamily:_fontFamily scaleFactor:self.weexInstance.pixelScaleFactor];
+    UIFont *font = [WXUtility fontWithSize:_fontSize textWeight:_fontWeight textStyle:_fontStyle fontFamily:_fontFamily scaleFactor:self.weexInstance.pixelScaleFactor useCoreText:[self useCoreText]];
     CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)font.fontName,
                                            font.pointSize,
                                            NULL);

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/41f524f4/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
index b265b23..39c4034 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
@@ -226,6 +226,8 @@ extern _Nonnull SEL WXSwizzledSelectorForSelector(_Nonnull SEL selector);
  */
 + (UIFont *_Nonnull)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString *_Nullable)fontFamily scaleFactor:(CGFloat)scaleFactor;
 
++ (UIFont *_Nonnull)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString *_Nullable)fontFamily scaleFactor:(CGFloat)scaleFactor useCoreText:(BOOL)useCoreText;
+
 /**
  * @abstract download remote font from specified url
  * @param fontURL for remote font

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/41f524f4/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index 22faf05..048e7bc 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -444,7 +444,7 @@ static BOOL WXNotStat;
     return [self fontWithSize:size textWeight:textWeight textStyle:textStyle fontFamily:fontFamily scaleFactor:[self defaultPixelScaleFactor]];
 }
 
-+ (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString *)fontFamily scaleFactor:(CGFloat)scaleFactor
++ (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString *)fontFamily scaleFactor:(CGFloat)scaleFactor useCoreText:(BOOL)useCoreText
 {
     CGFloat fontSize = (isnan(size) || size == 0) ?  32 * scaleFactor : size;
     UIFont *font = nil;
@@ -457,7 +457,7 @@ static BOOL WXNotStat;
             // if the font file is not the correct font file. it will crash by singal 9
             CFURLRef fontURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (__bridge CFStringRef)fpath, kCFURLPOSIXPathStyle, false);
             if (fontURL) {
-                if ([WXTextComponent useCoreText]) {
+                if (useCoreText) {
                     CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL(fontURL);
                     if (fontDataProvider) {
                         CGFontRef newFont = CGFontCreateWithDataProvider(fontDataProvider);
@@ -531,6 +531,11 @@ static BOOL WXNotStat;
     return font;
 }
 
++ (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString *)fontFamily scaleFactor:(CGFloat)scaleFactor
+{
+    return [self fontWithSize:size textWeight:textWeight textStyle:textStyle fontFamily:fontFamily scaleFactor:scaleFactor useCoreText:NO];
+}
+
 + (void)getIconfont:(NSURL *)url completion:(void(^)(NSURL *url, NSError *error))completionBlock
 {
     dispatch_async(dispatch_get_global_queue(0, 0), ^{