This is a thing. It just doesn’t work very reliably for the reasons you mentioned.
It does work kind of ok on some comics like the one OP shared and generally pretty well on manga since that tends to be more consistent with the boxes.
I don’t know of anything open source or self hosted that does this though.
Unboxious@ani.social 4 days ago
Even in the page given as an example here there are two speech bubbles that are pushing their boundaries.