summaryrefslogtreecommitdiff
path: root/tex/context/base/lpdf-fld.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-05-14 17:40:12 +0300
committerMarius <mariausol@gmail.com>2011-05-14 17:40:12 +0300
commitfefebde9e50a00034bc24315398d5796d9664ae6 (patch)
tree9a5a1646fcc5d8b7d65be703d72ef986c13648b3 /tex/context/base/lpdf-fld.lua
parentbcc46b67b4d49116c17086f6a20f6de1220dc688 (diff)
downloadcontext-fefebde9e50a00034bc24315398d5796d9664ae6.tar.gz
beta 2011.05.14 16:34
Diffstat (limited to 'tex/context/base/lpdf-fld.lua')
-rw-r--r--tex/context/base/lpdf-fld.lua30
1 files changed, 20 insertions, 10 deletions
diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua
index 9445333d7..590aee1ab 100644
--- a/tex/context/base/lpdf-fld.lua
+++ b/tex/context/base/lpdf-fld.lua
@@ -191,6 +191,8 @@ local pdfdocencodingvector, pdfdocencodingcapsule
-- a glyph is not in the vector, it is still visible
-- as it is taken from some other font. Messy.
+-- To be checked: only when text/line fields.
+
local function checkpdfdocencoding()
report_fields("adding pdfdoc encoding vector")
local encoding = dofile(resolvers.findfile("lpdf-enc.lua")) -- no checking, fatal if not present
@@ -269,7 +271,7 @@ end
local function registerfonts()
if next(usedfonts) then
- checkpdfdocencoding()
+ checkpdfdocencoding() -- already done
local d = pdfdictionary()
local pdffonttype, pdffontsubtype = pdfconstant("Font"), pdfconstant("Type1")
for tag, name in next, usedfonts do
@@ -650,9 +652,11 @@ end
-- finish
-local collected = pdfarray()
+local collected = pdfarray()
+local forceencoding = false
local function finishfields()
+ local sometext = forceencoding
for name, field in next, fields do
local kids = field.kids
if kids then
@@ -662,6 +666,10 @@ local function finishfields()
if opt then
pdfflushobject(field.optnum,opt)
end
+ local type = field.type
+ if not sometext and (type == "text" or type == "line") then
+ sometext = true
+ end
end
for name, field in next, radios do
local kids = field.kids
@@ -674,18 +682,20 @@ local function finishfields()
end
end
if #collected > 0 then
- checkpdfdocencoding()
- usedfonts.tttf = fontnames.tt.tf
local acroform = pdfdictionary {
NeedAppearances = true,
- Fields = pdfreference(pdfflushobject(collected)),
- DR = pdfdictionary {
+ Fields = pdfreference(pdfflushobject(collected)),
+ CO = fieldsetlist(calculationset),
+ }
+ if sometext then
+ checkpdfdocencoding()
+ usedfonts.tttf = fontnames.tt.tf
+ acroform.DA = "/tttf 12 Tf 0 g"
+ acroform.DR = pdfdictionary {
Font = registerfonts(),
Encoding = pdfdocencodingcapsule,
- },
- CO = fieldsetlist(calculationset),
- DA = "/tttf 12 Tf 0 g",
- }
+ }
+ end
lpdf.addtocatalog("AcroForm",pdfreference(pdfflushobject(acroform)))
end
end