[Gs-devel] [gs6.5x] sometimes ps2psf uses Tj after TL

mpsuzuki at hiroshima-u.ac.jp mpsuzuki at hiroshima-u.ac.jp
Sun Nov 25 23:56:38 PST 2001


Dear GNU GS maintainers,

Sometimes ps2pdf of gs6.5x misplaces glyphs by
using Tj after TL (' should be used after TL).

Please check:
bad example
	http://www.gyve.org/~mpsuzuki/ps2pdfbug/iso-2022-m17n_sol_gs6_pdf14.pdf
good example
	http://www.gyve.org/~mpsuzuki/ps2pdfbug/iso-2022-m17n_sol_gs7_pdf14.pdf

Following is the problematic part.
----------------------------------------------------------------------
private int
pdf_set_text_matrix(gx_device_pdf * pdev, const gs_matrix * pmat)
{
...
    if (pmat->xx == pdev->text.matrix.xx &&
        pmat->xy == pdev->text.matrix.xy &&
        pmat->yx == pdev->text.matrix.yx &&
        pmat->yy == pdev->text.matrix.yy &&
    /*
     * If we aren't already in text context, BT will reset
     * the text matrix.
     */
        (pdev->context == PDF_IN_TEXT || pdev->context == PDF_IN_STRING)
        ) {
        /* Use leading, Td or a pseudo-character. */

        if (dist.y == 0 && dist.x >= X_SPACE_MIN &&
            dist.x <= X_SPACE_MAX &&
            pdev->text.font != 0 &&
            PDF_FONT_IS_SYNTHESIZED(pdev->text.font)
            ) {                 /* Use a pseudo-character. */

        ...

            pdf_append_chars(pdev, &space_char, 1);
            pdev->text.current.x += dx * pmat->xx;
(A) =====>> pdev->text.use_leading = false;
            return 0;
      }
      not_spaces:
        code = pdf_open_page(pdev, PDF_IN_TEXT);
        if (code < 0)
            return code;

        if (dist.x == 0 && dist.y < 0) {
            /* Use TL, if needed, + '. */
            float dist_y = (float)-dist.y;

            if (fabs(pdev->text.leading - dist_y) > 0.0005) {
                pprintg1(s, "%g TL\n", dist_y);
                pdev->text.leading = dist_y;
            }
(B) =====>> pdev->text.use_leading = true;
        } else {
            /* Use Td. */
            set_text_distance(&dist, &pdev->text.line_start, pmat);
            pprintg2(s, "%g %g Td\n", dist.x, dist.y);
            pdev->text.use_leading = false;
        }
----------------------------------------------------------------------

When TL is used, use_leading is set to true at (B).
This values is used in string_to_text() at next time
of text rendering, to determin  Tj or '.

But, sometimes use_leading is reset to false at (A),
after (B) and before string_to_text(). In such case,
Tj is used where ' should be used, and the PDF result
misplaces some glyphs.

I didn't investigate the source code (to keep from
mixing AFPL code into GPL code), gs7.0x seems to be
free from such troubles. So only gs6.5x needs a fix.

There might be 2 different fixes:

	(1) disable the initialization of use_leading at (A).
		(proposed by Masatake Yamato)

	(2) disable TL itself around (B).
		(proposed by Taiji Yamada)

Which is better?

The former is along to original implementation, but I'm not
sure whether disabling (A) is enough (other variables should
be left or not?).

The latter is simple but not beautiful, I think.

Regards,

mpsuzuki




More information about the gs-devel mailing list