Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Conversation

samhsiung
Copy link
Contributor

After debugging #930 it was discovered that increasing the constrainedSize height slightly for ASTextKitRenderer's ASTextKitContext enabled it to truncate on the correct line rather than line N - 1.

After digging some more, found that ASTextKitContext's _layoutManager's usesFontLeading was set to NO. However we are using customized font leading in our project (though I'm not sure about ASTextNode in general), so this resulted in a discrepancy between the calculated shrunk size of the text node and the layout+truncation calculation.

I suspect it should be okay to remove overriding of usesFontLeading since apple docs state that the default is YES. I also think it is better to customize via the layoutManagerFactory parameter in ASTextKitContext's init method if usesFontLeading needs to be set to NO rather than overriding it for all cases.

Regardless, removing usesFontLeading = NO fixed #930 for me:

Before:
simulator screen shot dec 12 2015 8 16 48 pm

After:
simulator screen shot dec 12 2015 7 58 44 pm

@samhsiung samhsiung changed the title Fix truncation calculation by setting layoutManager.usesFontLeading = NO Fix truncation calculation by removing layoutManager.usesFontLeading = YES Dec 13, 2015
@samhsiung samhsiung changed the title Fix truncation calculation by removing layoutManager.usesFontLeading = YES Fix truncation calculation in ASTextNode by removing layoutManager.usesFontLeading = YES in renderer context Dec 13, 2015
@samhsiung
Copy link
Contributor Author

Actually, we're using customized line spacing at the paragraph level and not a customized font leading so I think it's some other issue.

@samhsiung samhsiung closed this Dec 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(ASDK 1.9.3) ASTextNode truncates on first line instead of second line for single words that are long enough

2 participants