Is there a command one can use in XeLaTeX and the rest of the TeX family to completely prevent any overlapping from occurring? Perhaps it could break the compilation with an error to alert you? I have found so many times that once you start playing around with embedded pdf's or even lettrines and placing text in the margins that there are almost always something ending up on top of another element. I don't provide a MWE because this problem is too general to confine it to one small example.
Edit: Example of an overlap
Edit 2: Working on documents of over 2500 pages it would really be helpful to detect overlaps automatically without having to manually scan through the final product each time.
It seems that the problem is that when you get a length for possible text to place by means of
\ifdimless then when the actual text is placed it is sometimes stretched or shrunk to fit into the space available. Thus rendering the text
textwidth which might be different from the value you have calculated previously.