Repository: incubator-weex Updated Branches: refs/heads/master cb452bf5b -> ce4b6bf00
[WEEX-173][iOS] iconfont redraw failed sometimes on iOS Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ce4b6bf0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ce4b6bf0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ce4b6bf0 Branch: refs/heads/master Commit: ce4b6bf005f74c8d4e43d2b86cc446061d90b109 Parents: cb452bf Author: acton393 <[email protected]> Authored: Mon Jan 22 22:01:53 2018 +0800 Committer: acton393 <[email protected]> Committed: Mon Jan 22 22:01:53 2018 +0800 ---------------------------------------------------------------------- .../WeexSDK/Sources/Component/WXTextComponent.m | 22 +++++++++----------- ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ce4b6bf0/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 5cdfd3d..65f7ae3 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m @@ -131,6 +131,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2; pthread_mutex_t _ctAttributedStringMutex; pthread_mutexattr_t _propertMutexAttr; + BOOL _observerIconfont; } + (void)setRenderUsingCoreText:(BOOL)usingCoreText @@ -187,7 +188,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2; - (void)dealloc { - if (_fontFamily) { + if (_fontFamily && _observerIconfont) { [[NSNotificationCenter defaultCenter] removeObserver:self name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil]; } pthread_mutex_destroy(&_ctAttributedStringMutex); @@ -250,7 +251,11 @@ do {\ WX_STYLE_FILL_TEXT_PIXEL(letterSpacing, letterSpacing, YES) WX_STYLE_FILL_TEXT(wordWrap, wordWrap, NSString, YES); WX_STYLE_FILL_TEXT(direction, direction, NSString, YES) - + if (_fontFamily && !_observerIconfont) { + // notification received when custom icon font file download finish + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repaintText:) name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil]; + _observerIconfont = YES; + } UIEdgeInsets padding = { WXFloorPixelValue(self.cssNode->style.padding[CSS_TOP] + self.cssNode->style.border[CSS_TOP]), WXFloorPixelValue(self.cssNode->style.padding[CSS_LEFT] + self.cssNode->style.border[CSS_LEFT]), @@ -381,6 +386,9 @@ do {\ pthread_mutex_lock(&(_ctAttributedStringMutex)); if (!_ctAttributedString) { _ctAttributedString = [self buildCTAttributeString]; + WXPerformBlockOnComponentThread(^{ + [self.weexInstance.componentManager startComponentTasks]; + }); } attributedString = [_ctAttributedString copy]; pthread_mutex_unlock(&(_ctAttributedStringMutex)); @@ -414,11 +422,6 @@ do {\ [attributedString addAttribute:NSForegroundColorAttributeName value:_color range:NSMakeRange(0, string.length)]; } - if (_fontFamily) { - // notification received when custom icon font file download finish - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repaintText:) name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil]; - } - // set font 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, @@ -505,11 +508,6 @@ do {\ [attributedString addAttribute:NSForegroundColorAttributeName value:_color range:NSMakeRange(0, string.length)]; } - if (_fontFamily) { - // notification received when custom icon font file download finish - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repaintText:) name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil]; - } - // set font UIFont *font = [WXUtility fontWithSize:_fontSize textWeight:_fontWeight textStyle:_fontStyle fontFamily:_fontFamily scaleFactor:self.weexInstance.pixelScaleFactor]; if (font) { http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ce4b6bf0/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m b/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m index dc12207..5125194 100644 --- a/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m +++ b/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m @@ -84,7 +84,7 @@ static WXRuleManager *_sharedInstance = nil; fontSrc = newURL; NSMutableDictionary * fontFamily = [self.fontStorage objectForKey:rule[@"fontFamily"]]; - if (fontFamily && [fontFamily[@"src"] isEqualToString:fontSrc]) { + if (fontFamily && [fontFamily[@"tempSrc"] isEqualToString:fontSrc]) { // if the new src is same as src in dictionary , ignore it, or update it return; }
