I'm trying to render text with dompdf. It should look exactly like in the browser. That works, as long as the characters of the words are not formatted:
With HTML like:
<span style="color: #000000; font-family:'opensans'">
<p style="font-size: 30.57465524239px;">
This Text is a test to show the different behaviour!
</p>
</span>
Browser text without formats
dompdf text without formats
But if I want to give the characters different styles, with HTML like:
<span style="color: #000000; font-family:'opensans'">
<p style="font-size: 30px;">
This Text is a test to
<span style="color: #800080;">s</span>
<span style="color: #ff0000;">h</span>
<span style="color: #000080;">o</span>
<span style="color: #003300;">w</span>
<span style="color: #000080;">t</span>
<span style="color: #ff00ff;">h</span>
<span style="color: #ff0000;">e
<span style="color: #000000;">different behaviour!</span>
</span>
</p>
</span>
The browser still displays it like intended:
But dompdf displays it like word-break: break-all;
would be active.
I have already tried to add word-break: keep-all;
to the surrounding <span>
or <p>
. I have also tried to surround the words with another <span>
or <nobr>
element, but that didn't change anything.
So, my question is, how can I get dompdf to keep the normal word-break
rules on words with formatted characters?