/* * Set the text matrix for writing text. The translation component of the * matrix is the text origin. If the non-translation components of the * matrix differ from the current ones, write a Tm command; if there is only * a Y translation, set use_leading so the next text string will be written * with ' rather than Tj; otherwise, write a Td command. */ static int pdf_set_text_matrix(gx_device_pdf * pdev) { pdf_text_state_t *pts = pdev->text->text_state; stream *s = pdev->strm; pts->use_leading = false; if (matrix_is_compatible(&pts->out.matrix, &pts->in.matrix)) { gs_point dist; int code; code = set_text_distance(&dist, pts->start.x - pts->line_start.x, pts->start.y - pts->line_start.y, &pts->in.matrix); if (code < 0) return code; if (dist.x == 0 && dist.y < 0) { /* Use TL, if needed, and T* or '. */ float dist_y = (float)-dist.y; if (fabs(pts->leading - dist_y) > 0.0005) { pprintg1(s, "%g TL\n", dist_y); pts->leading = dist_y; } pts->use_leading = true; } else { /* Use Td. */ pprintg2(s, "%g %g Td\n", dist.x, dist.y); } } else { /* Use Tm. */ /* * See stream_to_text in gdevpdfu.c for why we need the following * matrix adjustments. */ double sx = 72.0 / pdev->HWResolution[0], sy = 72.0 / pdev->HWResolution[1]; pprintg6(s, "%g %g %g %g %g %g Tm\n", pts->in.matrix.xx * sx, pts->in.matrix.xy * sy, pts->in.matrix.yx * sx, pts->in.matrix.yy * sy, pts->start.x * sx, pts->start.y * sy); } pts->line_start.x = pts->start.x; pts->line_start.y = pts->start.y; pts->out.matrix = pts->in.matrix; return 0; }
const char * pprintg4(stream * s, const char *format, floatp v1, floatp v2, floatp v3, floatp v4) { return pprintg2(s, pprintg2(s, format, v1, v2), v3, v4); }
const char * pprintg3(stream * s, const char *format, floatp v1, floatp v2, floatp v3) { return pprintg2(s, pprintg1(s, format, v1), v2, v3); }