weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sospar...@apache.org
Subject [02/14] incubator-weex git commit: * [ios] fix bug uifont lead crash in iOS system less than 8.2 #2769
Date Thu, 02 Mar 2017 03:31:17 GMT
* [ios] fix bug uifont lead crash in iOS system less than 8.2 #2769


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

Branch: refs/heads/dev
Commit: 59eba97035be5062515ee749e31a06c6c924535d
Parents: 5529bb1
Author: kfeagle <sunjjbobo@163.com>
Authored: Fri Feb 24 18:14:45 2017 +0800
Committer: kfeagle <sunjjbobo@163.com>
Committed: Fri Feb 24 18:14:45 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/59eba970/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 dde3ffb..23b1b1b 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -356,19 +356,27 @@ static BOOL WXNotStat;
     if (!font) {
         if (fontFamily) {
             font = [UIFont fontWithName:fontFamily size:fontSize];
-            if (!font) {
+        }
+        if (!font) {
+            if (fontFamily) {
                 WXLogWarning(@"Unknown fontFamily:%@", fontFamily);
+            }
+            if(WX_SYS_VERSION_LESS_THAN(@"8.2")) {
+                font = [UIFont systemFontOfSize:fontSize];
+            } else {
                 font = [UIFont systemFontOfSize:fontSize weight:textWeight];
             }
-        } else {
-            font = [UIFont systemFontOfSize:fontSize weight:textWeight];
         }
     }
     UIFontDescriptor *fontD = font.fontDescriptor;
     UIFontDescriptorSymbolicTraits traits = 0;
     
     traits = (textStyle == WXTextStyleItalic) ? (traits | UIFontDescriptorTraitItalic) :
traits;
-    traits = (fabs(textWeight-(WX_SYS_VERSION_LESS_THAN(@"8.2")?0.4:UIFontWeightBold)) <=
1e-6) ? (traits | UIFontDescriptorTraitBold) : traits;
+    if (WX_SYS_VERSION_LESS_THAN(@"8.2")) {
+        traits = ((textWeight-0.4) >= 0.0) ? (traits | UIFontDescriptorTraitBold) : traits;
+    }else {
+        traits = (textWeight-UIFontWeightBold >= 0.0) ? (traits | UIFontDescriptorTraitBold)
: traits;
+    }
     if (traits != 0) {
         fontD = [fontD fontDescriptorWithSymbolicTraits:traits];
         UIFont *tempFont = [UIFont fontWithDescriptor:fontD size:0];


Mime
View raw message