Skip to content

[ASTextNode] Unnecessary Text Layout in ASTextKitRenderer #156

Open
@garrettmoon

Description

@garrettmoon

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions