aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFFormFieldObjectHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-21 04:39:25 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-21 05:05:58 +0100
commit9cb599875bbd1aaf1d2e91d44201ee0fcb79418f (patch)
tree953d9c1d03650c52c5c8f68236db9dbef1fc4cb4 /libqpdf/QPDFFormFieldObjectHelper.cc
parent930eade6d36060b1bdc5934e74952fa6bcfdb07f (diff)
downloadqpdf-9cb599875bbd1aaf1d2e91d44201ee0fcb79418f.tar.zst
Improve text objects used in text appearance streams
Diffstat (limited to 'libqpdf/QPDFFormFieldObjectHelper.cc')
-rw-r--r--libqpdf/QPDFFormFieldObjectHelper.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc
index ccc19cb5..da49505a 100644
--- a/libqpdf/QPDFFormFieldObjectHelper.cc
+++ b/libqpdf/QPDFFormFieldObjectHelper.cc
@@ -673,7 +673,6 @@ ValueSetter::writeAppearance()
// Write the lines centered vertically, highlighting if needed
size_t nlines = lines.size();
double dy = bbox.ury - ((bbox.ury - bbox.lly - (nlines * tfh)) / 2.0);
- write(DA + "\nq\n");
if (highlight)
{
write("q\n0.85 0.85 0.85 rg\n" +
@@ -684,17 +683,26 @@ ValueSetter::writeAppearance()
QUtil::double_to_string(tfh) +
" re f\nQ\n");
}
- dy += 0.2 * tf;
+ dy -= tf;
+ write("q\nBT\n" + DA + "\n");
for (size_t i = 0; i < nlines; ++i)
{
- dy -= tfh;
- write("BT\n" +
- QUtil::int_to_string(bbox.llx + dx) + " " +
- QUtil::double_to_string(bbox.lly + dy) + " Td\n" +
- QPDFObjectHandle::newString(lines.at(i)).unparse() +
- " Tj\nET\n");
+ // We could adjust Tm to translate to the beginning the first
+ // line, set TL to tfh, and use T* for each subsequent line,
+ // but doing this would require extracting any Tm from DA,
+ // which doesn't seem really worth the effort.
+ if (i == 0)
+ {
+ write(QUtil::int_to_string(bbox.llx + dx) + " " +
+ QUtil::double_to_string(bbox.lly + dy) + " Td\n");
+ }
+ else
+ {
+ write("0 " + QUtil::double_to_string(-tfh) + " Td\n");
+ }
+ write(QPDFObjectHandle::newString(lines.at(i)).unparse() + " Tj\n");
}
- write("Q\nEMC");
+ write("ET\nQ\nEMC");
}
class TfFinder: public QPDFObjectHandle::TokenFilter