Still have no idea about how to specify fonts in JavaScript fields.
![](https://secure.gravatar.com/avatar/117a058bed6945e7fa1b40ff2f6e7aa7.jpg?s=120&d=mm&r=g)
Hello everyone, Thanks for suggesting some great documents last time. But after looking up in AcroJS Guide, and PDF Reference , etc., I still don't know how can I use special fonts in a JavaScript field. My JS code is: ------------------------------------------------------------------------------------------ function start_clock() { var thetime=new Date(); var nhours=thetime.getHours(); var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); if (nhours<0) nhours="0"+nhours; if (nsecn<10) nsecn="0"+nsecn; if (nmins<10) nmins="0"+nmins; font.Digital = font.CourBI ; vv = this.getField("time.clock") ; if (vv) { vv.value = nhours+":"+nmins+":"+nsecn; vv.readonly = true ; vv.textColor = color.red ; vv.textFont = font.Digital ; // font.TimesBI Cour HelvB Symbol ZapfD this.dirty = false }} timeout=app.setInterval('start_clock()',1000); ------------------------------------------------------------------------------------------ I guess there are already some definitions about ``font.CourBI'' but where can I find the original code of the definition which I can imitate it to create a new font. Thanks -- Sincerely yours, Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
Zhichu Chen wrote:
Hello everyone,
Thanks for suggesting some great documents last time. But after looking up in AcroJS Guide, and PDF Reference , etc., I still don't know how can I use special fonts in a JavaScript field.
My JS code is: ------------------------------------------------------------------------------------------ function start_clock() { var thetime=new Date(); var nhours=thetime.getHours(); var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); if (nhours<0) nhours="0"+nhours; if (nsecn<10) nsecn="0"+nsecn; if (nmins<10) nmins="0"+nmins; font.Digital = font.CourBI ; vv = this.getField("time.clock") ; if (vv) { vv.value = nhours+":"+nmins+":"+nsecn; vv.readonly = true ; vv.textColor = color.red ; vv.textFont = font.Digital ; // font.TimesBI Cour HelvB Symbol ZapfD this.dirty = false }}
timeout=app.setInterval('start_clock()',1000); ------------------------------------------------------------------------------------------
I guess there are already some definitions about ``font.CourBI'' but where can I find the original code of the definition which I can imitate it to create a new font.
\startJScode{oeps} var f = this.getField("TestField") ; if (f) { if (f.textFont == "Times-Roman") { f.textFont = "LMRoman12-Regular"; } else { f.textFont = "Times-Roman"; } } \stopJScode \setupinteraction[state=start] \pdfcompresslevel=0 \starttext \definefield[TestField][text] [TestGroup][][some example text] \definefield[FontField][check][FontGroup][yes,no][no] \definesymbol[yes][\strut YES] \definesymbol[no] [\strut NO] \setupfield[TestGroup][none][width=10cm] \setupfield[FontGroup][none][width=3cm,height=2cm,clickin=JS(oeps)] \field[TestField] \field[FontField] abcdefghijklmnopqrstuvwxyz \stoptext The problem is that a subsetted font has no known name (prefix is random); however, when embedded full it does not work either ("Courier" does work). Maybe there is special trickery needed to let acrobat know what fonts can be used. We may as well need some new pdftex code for this. I cc to Hartmut who is the pdftex teams weird-font-issues wizzard. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/117a058bed6945e7fa1b40ff2f6e7aa7.jpg?s=120&d=mm&r=g)
Hi, Hans Thank you for your example. I just figured out that once PDF cannot find the specified font, it will look for a truetype font which has the similar font metrics. Now I know what to do and has just succeeded: First, I install a truetype font to ConTeXt---by using texfont of course---so that ConTeXt can use it; Then specify the field's textFont attribution to the truetype font name; Finally, it looks all great. I think it should work on Type1 fonts too. I hope I can attach all .ttf, .tfm files to you, but it seems that the mailing list has a 40K limitation. -- Sincerely yours, Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
Zhichu Chen wrote:
First, I install a truetype font to ConTeXt---by using texfont of course---so that ConTeXt can use it; Then specify the field's textFont attribution to the truetype font name; Finally, it looks all great. does not work here, so maybe you need the (Digital) font on your system.
btw, also set a closeaction which kills the clock when you close the document, otherwise acrobat will keep running and freeze Hans
I hope I can attach all .ttf, .tfm files to you, but it seems that the mailing list has a 40K limitation.
just send me the mail directly Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Zhichu Chen