The initial implementation using Layout#getOffsetForHorizontal could
miss whitespace characters at the endpoints. This new implementation
using Layout#getRangeForRect ensures all whitespace characters touched
are included in the range.
Bug: 247557062
Test: atest android.widget.cts.TextViewHandwritingGestureTest
Change-Id: I800407a6d89d77cd5e750530d9dae8ccb268869f