mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Stopped trying to cache the currentScaleFactor
Was running into issues where the scale factor would get cleared when setting a new atributedString on a textNode. I was clearing out the currentScaleFactor when setting an attributedString into a textNode. It appears that `_calculateSize` isn't always called when setting a new string into a ASTextNode. It can be the case that only `drawInContext:bounds:` is called. With _currentScaleFactor cleared out the renderer that calls`drawInContext...` was being called with a scaleFactor of 0. It could be the case that the fix could be to remove the clearing of `currentScaleFactor` from `setAttributedString`, but this seems like a safer fix to me. It does, however, require an extra run through the font adjuster when enabled.
This commit is contained in:
@@ -244,7 +244,6 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
.maximumNumberOfLines = _maximumNumberOfLines,
|
||||
.exclusionPaths = _exclusionPaths,
|
||||
.pointSizeScaleFactors = _pointSizeScaleFactors,
|
||||
.currentScaleFactor = self.currentScaleFactor,
|
||||
.layoutManagerCreationBlock = self.layoutManagerCreationBlock,
|
||||
.textStorageCreationBlock = self.textStorageCreationBlock,
|
||||
};
|
||||
@@ -338,10 +337,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
|
||||
CGSize size = [[self _renderer] size];
|
||||
// the renderer computes the current scale factor during sizing, so let's grab it here
|
||||
_currentScaleFactor = _renderer.currentScaleFactor;
|
||||
return size;
|
||||
return [[self _renderer] size];
|
||||
}
|
||||
|
||||
#pragma mark - Modifying User Text
|
||||
@@ -380,8 +376,6 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
self.isAccessibilityElement = YES;
|
||||
}
|
||||
|
||||
// reset the scale factor if we get a new string.
|
||||
_currentScaleFactor = 0;
|
||||
if (attributedString.length > 0) {
|
||||
CGFloat screenScale = ASScreenScale();
|
||||
self.ascender = round([[attributedString attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL] ascender] * screenScale)/screenScale;
|
||||
|
||||
Reference in New Issue
Block a user