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/03/22 02:00:05 UTC
[32/50] incubator-weex git commit: * [ios] draw iconfont use coreText
* [ios] draw iconfont use coreText
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ece390f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ece390f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ece390f3
Branch: refs/heads/0.12-dev
Commit: ece390f36b29fa9d61af89c5e9a98f4ed57dc62a
Parents: 3a1cc07
Author: acton393 <zh...@gmail.com>
Authored: Fri Mar 17 21:57:10 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Mar 17 21:57:10 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 27 +++++++++++++++---------
1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ece390f3/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 12677e3..2289646 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -342,19 +342,26 @@ static BOOL WXNotStat;
if ([self isFileExist:fpath]) {
// 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);
- CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL(fontURL);
if (fontURL) {
+ CFErrorRef error = nil;
+ CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error);
+ if (error) {
+ CFRelease(error);
+ error = nil;
+ CTFontManagerUnregisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error);
+ CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error);
+ }
+ NSArray *descriptors = (__bridge_transfer NSArray *)CTFontManagerCreateFontDescriptorsFromURL(fontURL);
+ // length of descriptors here will be only one.
+ for (NSFontDescriptor *desc in descriptors) {
+ font = [UIFont fontWithDescriptor:desc size:fontSize];
+ }
CFRelease(fontURL);
+ if (error) {
+ CFRelease(error);
+ }
}
- CGFontRef graphicFont = CGFontCreateWithDataProvider(fontDataProvider);
- if (fontDataProvider) {
- CGDataProviderRelease(fontDataProvider);
- }
- CTFontRef smallFont = CTFontCreateWithGraphicsFont(graphicFont, size, NULL, NULL);
- if (graphicFont) {
- CFRelease(graphicFont);
- }
- font = (__bridge_transfer UIFont*)smallFont;
+
}else {
[[WXRuleManager sharedInstance] removeRule:@"fontFace" rule:@{@"fontFamily": fontFamily}];
}