@DTS Engineer
thank you for your suggestion. I tried that approach now (and before) and it looks like calling enumerateTextLayoutFragments yields approximate/estimate layout positions.
Specifically, calling the suggested routine multiple times returns different values:
var lastLayoutFragment: NSTextLayoutFragment!
textLayoutManager.enumerateTextLayoutFragments(from: textLayoutManager.documentRange.endLocation,
options: [.reverse, .ensuresLayout]) { layoutFragment in
lastLayoutFragment = layoutFragment
return false
}
let lastLineMaxY = lastLayoutFragment.layoutFragmentFrame.maxY
print(lastLineMaxY)
in my test case case result with these values:
4302376.62016702
4092451.6843738933
3979224.5583475474
4565598.13343745
4332115.927268179
4331192.884374112
4331192.884374112
4331192.884374112
4331192.884374112
4331192.884374112
as we can see, the value eventually get "stable" and that is actuall height of the document. The initial values jumps (estimate) up and down without the pattern.
That behavior is aligned with values reported by usageBoundsForTextContainer and is a root of many issues.
In the example you provided is not different, hence I'd like to ask how does it suppose to work with estimated layout values?