summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2021-04-12 08:23:11 +0100
committerChris Liddell <chris.liddell@artifex.com>2021-04-12 08:26:06 +0100
commitb4c810ee9e40aa03835e3fc9423a8bbb9412010b (patch)
treed65395c0675c1eb85f0e73546fc83b17bed20ddd
parentea6fa00c8b15c8d9567013e3792fdb8927d55029 (diff)
downloadghostpdl-b4c810ee9e40aa03835e3fc9423a8bbb9412010b.tar.gz
Correctly scale the character spacing (Tc)
For CIDFonts and fonts without a Widths array, we apply the character spacing value differently - normally, we'll add the Tc value to the value read from the Widths array. But in the other case, we use the graphics library's feature for adding a value to the advance width of each glyph in a string. It turns out, however, that these require different scaling of the width value.
-rw-r--r--pdf/pdf_text.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pdf/pdf_text.c b/pdf/pdf_text.c
index 78b3cca25..bbd798755 100644
--- a/pdf/pdf_text.c
+++ b/pdf/pdf_text.c
@@ -388,7 +388,11 @@ static int pdfi_show_set_params(pdf_context *ctx, pdf_string *s, gs_text_params_
text->operation = TEXT_RETURN_WIDTH;
if (Tc != 0) {
text->operation |= TEXT_ADD_TO_ALL_WIDTHS;
- text->delta_all.x = Tc;
+ /* Division by PDFfontsize because these are in unscaled font units,
+ and the font scale is now pickled into the text matrix, so we have to
+ undo that.
+ */
+ text->delta_all.x = Tc / ctx->pgs->PDFfontsize;
text->delta_all.y = 0;
}
} else {
@@ -430,6 +434,10 @@ static int pdfi_show_set_params(pdf_context *ctx, pdf_string *s, gs_text_params_
Tw = gs_currentwordspacing(ctx->pgs);
if (Tw != 0) {
text->operation |= TEXT_ADD_TO_SPACE_WIDTH;
+ /* Division by PDFfontsize because these are in unscaled font units,
+ and the font scale is now pickled into the text matrix, so we have to
+ undo that.
+ */
text->delta_space.x = Tw / ctx->pgs->PDFfontsize;
text->delta_space.y = 0;
text->space.s_char = 0x20;