You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/11/23 06:42:00 UTC
[jira] [Commented] (WEEX-449) Iconfont character may randomly
display as '?'
[ https://issues.apache.org/jira/browse/WEEX-449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16696426#comment-16696426 ]
ASF GitHub Bot commented on WEEX-449:
-------------------------------------
wqyfavor closed pull request #1306: [WEEX-449][iOS] Fix issue that iconfont may randomly display as '?'.
URL: https://github.com/apache/incubator-weex/pull/1306
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 952b446bbb..a2ab434ede 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -322,6 +322,9 @@ - (BOOL)_handleConfigCenter
[WXTextComponent setRenderUsingCoreText:useCoreText];
BOOL useThreadSafeLock = [[configCenter configForKey:@"iOS_weex_ext_config.useThreadSafeLock" defaultValue:@YES isDefault:NULL] boolValue];
[WXUtility setThreadSafeCollectionUsingLock:useThreadSafeLock];
+
+ BOOL unregisterFontWhenCollision = [[configCenter configForKey:@"iOS_weex_ext_config.unregisterFontWhenCollision" defaultValue:@NO isDefault:NULL] boolValue];
+ [WXUtility setUnregisterFontWhenCollision:unregisterFontWhenCollision];
//Reading config from orange for Release instance in Main Thread or not
_bReleaseInstanceInMainThread = [[configCenter configForKey:@"iOS_weex_ext_config.releaseInstanceInMainThread" defaultValue:@(YES) isDefault:nil] boolValue];
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
index aee32c2e20..53d1308aa9 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
@@ -487,4 +487,6 @@ BOOL WXFloatGreaterThanWithPrecision(CGFloat a,CGFloat b,double precision);
+ (BOOL)threadSafeCollectionUsingLock;
++ (void)setUnregisterFontWhenCollision:(BOOL)value;
+
@end
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index 567ba9a261..f2e325efa1 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -42,6 +42,7 @@
#define KEY_USERNAME_PASSWORD @"com.taobao.Weex.weex123456"
static BOOL threadSafeCollectionUsingLock = YES;
+static BOOL unregisterFontWhenCollision = NO;
void WXPerformBlockOnMainThread(void (^ _Nonnull block)(void))
{
@@ -147,6 +148,11 @@ + (BOOL)threadSafeCollectionUsingLock
return threadSafeCollectionUsingLock;
}
++ (void)setUnregisterFontWhenCollision:(BOOL)value
+{
+ unregisterFontWhenCollision = value;
+}
+
+ (void)performBlock:(void (^)(void))block onThread:(NSThread *)thread
{
if (!thread || !block) return;
@@ -486,14 +492,18 @@ + (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:
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);
+ if (unregisterFontWhenCollision) {
+ 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);
+ }
+ }
+ else {
CTFontManagerRegisterGraphicsFont(newFont, NULL);
- CFRelease(error);
- error = nil;
}
fontFamily = (__bridge_transfer NSString*)CGFontCopyPostScriptName(newFont);
CGFontRelease(newFont);
@@ -501,12 +511,16 @@ + (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:
CFRelease(fontDataProvider);
}
} else {
- CFErrorRef error = nil;
- CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error);
- if (error) {
- CFRelease(error);
- error = nil;
- CTFontManagerUnregisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL);
+ if (unregisterFontWhenCollision) {
+ CFErrorRef error = nil;
+ CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error);
+ if (error) {
+ CTFontManagerUnregisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL);
+ CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL);
+ CFRelease(error);
+ }
+ }
+ else {
CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL);
}
NSArray *descriptors = (__bridge_transfer NSArray *)CTFontManagerCreateFontDescriptorsFromURL(fontURL);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
> Iconfont character may randomly display as '?'
> ----------------------------------------------
>
> Key: WEEX-449
> URL: https://issues.apache.org/jira/browse/WEEX-449
> Project: Weex
> Issue Type: Bug
> Components: iOS
> Affects Versions: 0.12
> Reporter: Wang Qianyuan
> Assignee: acton393
> Priority: Major
> Attachments: 图片.png
>
> Original Estimate: 1m
> Remaining Estimate: 1m
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)