From 909a87a15b5f8fede1f6bfeac2005327a7ca1601 Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Mon, 22 Jul 2019 13:07:59 +0100 Subject: Permit extra widths on space glyphs (PDF Tw value) even for xyshow For the benefit of the pdfi interpreter. With the PDF in PostScript current interpreter, we apply Widths using a cshow procedure. The pdfi interpreter instead uses the x_widths and y_widths arrays, intended for use with the PostScript xyshow operator instead. However, the existing code doesn't add the extra width to space glyphs if we have TEXT_REPLACE_WIDTHS set (ie an xyshow). Here we move the code for the additional width out of the 'else' clause in show_move() so that we always have the value available. We then apply the dx and/or dy values in both cases. We also need to relax the 'invalid' checking which is performed at a higher level in the code (gx_device_text_begin) because this combination is explicitly barred there and returns an error. --- base/gxchar.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'base/gxchar.c') diff --git a/base/gxchar.c b/base/gxchar.c index 0188b4398..0c86e983c 100644 --- a/base/gxchar.c +++ b/base/gxchar.c @@ -890,6 +890,22 @@ show_move(gs_show_enum * penum) { gs_gstate *pgs = penum->pgs; int code; + double dx = 0, dy = 0; + + /* Specifically for applying PDF word spacing, if single_byte_space == true + we'll only apply the delta for single byte character codes == space.s_char + See psi/zchar.c zpdfwidthshow and zpdfawidthshow for more detail + */ + if (SHOW_IS_ADD_TO_SPACE(penum) + && (!penum->single_byte_space + || penum->bytes_decoded == 1)) { + gs_char chr = gx_current_char((const gs_text_enum_t *)penum); + + if (chr == penum->text.space.s_char) { + dx = penum->text.delta_space.x; + dy = penum->text.delta_space.y; + } + } if (SHOW_IS(penum, TEXT_REPLACE_WIDTHS)) { gs_point dpt; @@ -897,25 +913,12 @@ show_move(gs_show_enum * penum) code = gs_text_replaced_width(&penum->text, penum->xy_index - 1, &dpt); if (code < 0) return code; + dpt.x += dx; + dpt.y += dy; code = gs_distance_transform2fixed(&pgs->ctm, dpt.x, dpt.y, &penum->wxy); if (code < 0) return code; } else { - double dx = 0, dy = 0; - /* Specifically for applying PDF word spacing, if single_byte_space == true - we'll only apply the delta for single byte character codes == space.s_char - See psi/zchar.c zpdfwidthshow and zpdfawidthshow for more detail - */ - if (SHOW_IS_ADD_TO_SPACE(penum) - && (!penum->single_byte_space - || penum->bytes_decoded == 1)) { - gs_char chr = gx_current_char((const gs_text_enum_t *)penum); - - if (chr == penum->text.space.s_char) { - dx = penum->text.delta_space.x; - dy = penum->text.delta_space.y; - } - } if (SHOW_IS_ADD_TO_ALL(penum)) { dx += penum->text.delta_all.x; dy += penum->text.delta_all.y; -- cgit v1.2.1