This is probably harder than you think.
Drawing such a line is mainly based on randomness. For example, between "M" and "N" in your picture, I think that there is not one, but four consecutive small lines of different sizes of the brush (randomly selected in a small interval). Take a closer look and you will see them.
The coordinates of these four small lines are also arbitrarily adjusted (to a very small extent) to avoid the straight line that was once collected.
There may also be a random number of small lines between two squares (I think there are more than four small lines between "R" and "X").
You can try to find a library that already does the job, I don’t know if it is, but it is not possible.
source share