TextureGroup / Texture

Smooth asynchronous user interfaces for iOS apps.
https://texturegroup.org/
Other
8.02k stars 1.29k forks source link

[ASTextNode] Unnecessary Text Layout in ASTextKitRenderer #156

Open garrettmoon opened 7 years ago

garrettmoon commented 7 years ago

From @b3ll on November 13, 2016 11:9

Currently ASTextKitRenderer (ASDK 1.9.92) uses the bounds of the text container to render the required glyphs, rather than the bounds passed in through -drawInContext:bounds:.

NSRange glyphRange = [layoutManager glyphRangeForBoundingRect:CGRectMake(0,0,textContainer.size.width, textContainer.size.height) inTextContainer:textContainer];

[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:shadowInsetBounds.origin];
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:shadowInsetBounds.origin];`

Is there any reason for this?

I'm currently laying out text in a UIScrollView, which can change dynamically, and I'd rather it not redraw the entire scrollview's -contentSize of glyphs, since that can be extremely expensive. For larger sets of text, it's actually impossible to draw the whole set since it ends up being so memory intensive.

Copied from original issue: facebookarchive/AsyncDisplayKit#2600

garrettmoon commented 7 years ago

I don't think this is as urgent as a P1, but we should definitely prioritize for 2.1