int[] (float startX, float x) { float relX = x - startX; float prevPos = 0; int columnCount = getCodePointCount(); for (int i = 0; i < columnCount; i++) { int visualOffset = visualColumnToVisualOffset(i); float newPos = myCharPositions[visualOffset]; if (relX < (newPos + prevPos) / 2) { return new int[] {i, relX <= prevPos ? 0 : 1}; } prevPos = newPos; } return new int[] {columnCount, relX <= myCharPositions[myCharPositions.length - 1] ? 0 : 1}; }