You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/17 05:49:17 UTC

[13/50] [abbrv] incubator-weex git commit: Revert "Revert "* [ios] iconfont refactor""

Revert "Revert "* [ios] iconfont refactor""

This reverts commit e443027c1caaf3042995303f412168033b9378f8.


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

Branch: refs/heads/dev
Commit: 57b37bd45f3fd2238d7f7cb03d5e339f6a584486
Parents: e443027
Author: acton393 <zh...@gmail.com>
Authored: Thu Apr 13 17:08:46 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Apr 13 17:08:46 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 30 ++++++++++++++----------
 1 file changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/57b37bd4/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 6cb5334..466a563 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -455,20 +455,24 @@ 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) {
-                CFErrorRef error = nil;
-                CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error);
-                if (error) {
-                    CFRelease(error);
-                    error = nil;
-                    CTFontManagerUnregisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL);
-                    CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL);
+                CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL(fontURL);
+                if (fontDataProvider) {
+                    CGFontRef newFont = CGFontCreateWithDataProvider(fontDataProvider);
+                    CFErrorRef error = nil;
+                    CTFontManagerRegisterGraphicsFont(newFont, &error);
+                    // the same font family, remove it and register new one.
+                    if (error) {
+                        CTFontManagerUnregisterGraphicsFont(newFont, NULL);
+                        CTFontManagerRegisterGraphicsFont(newFont, NULL);
+                        CFRelease(error);
+                        error = nil;
+                    }
+                    fontFamily = (__bridge_transfer  NSString*)CGFontCopyPostScriptName(newFont);
+                    CGFontRelease(newFont);
+                    CFRelease(fontURL);
+                    CFRelease(fontDataProvider);
                 }
-                NSArray *descriptors = (__bridge_transfer NSArray *)CTFontManagerCreateFontDescriptorsFromURL(fontURL);
-                // length of descriptors here will be only one.
-                for (UIFontDescriptor *desc in descriptors) {
-                    font = [UIFont fontWithDescriptor:desc size:fontSize];
-                }
-                CFRelease(fontURL);
+                
             }
         }else {
             [[WXRuleManager sharedInstance] removeRule:@"fontFace" rule:@{@"fontFamily": fontFamily}];