This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Fix truncation calculation in ASTextNode by removing layoutManager.usesFontLeading = YES in renderer context #936
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
'susesFontLeading
was set to NO. However we are using customized font leading in our project (though I'm not sure aboutASTextNode
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 inASTextKitContext
's init method ifusesFontLeading
needs to be set to NO rather than overriding it for all cases.Regardless,
removing usesFontLeading = NO
fixed #930 for me:Before:

After:
