<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [fix] word wrapping of pdf stream causes gaps in the middle of text when printing"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=89406">89406</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[fix] word wrapping of pdf stream causes gaps in the middle of text when printing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>cairo
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>pdf backend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>ajohnson@redneon.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>john.mcpherson@opalle.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>cairo-bugs@cairographics.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>cairo version 1.13.0

When printing via CUPS (which uses cairo to create pdf files), sometimes
several spaces occur in the middle of words, pushing the rest of the sentence
to the right.

(as reported at <a href="https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/657094">https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/657094</a>):

######

This happens because cairo is putting newline "\n" characters into the stream
when creating PDF files (before compressing the stream), in an attempt to do
word-wrapping to keep the line size short (I think 72 columns?).

PDFs created like this appear ok on screen in evince, ghostscript etc, but some
printers don't like this - our institution has big Fuji Xerox machines and
these newline characters get turned into several spaces, which screws up the
horizontal spacing at what looks like random character positions.

For example, here is an extract of a deflated stream from one such PDF file:

[(M358)-10( )]TJ
-13.196 -1.15 Td
[(The Univ)-6(er)3(s)-4(i)-4(t)-8(y)11( of)-9( W)-3(es)-4(tern Aus)-4(tra\
li)-5(a )]TJ

on screen it looks like
"M358
The University of Western Australia"

but printed it becomes
"M358
The University of Western Austra lia"

The original PDF file doesn't have this, but evince uses libcairo to create the
print data, so the file sent to CUPS has the "\\\n" added to the middle of
strings in the stream. Printing the original PDF file directly with lpr does
not have this problem.

The code that is doing this is the _word_wrap_stream_count_string_up_to()
function in src/cairo-pdf-operators.c

            } else if (stream->column > stream->max_column) {
                newline = TRUE;
                break;
            }
...
    if (newline) {
        _cairo_output_stream_printf (stream->output, "\\\n");
        stream->column = 0;
    }

if either of these bits of code is disabled, then the problem is fixed.

######

ie please don't word wrap if we are inside an open text (...) element.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>