ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Still have no idea about how to specify fonts in JavaScript fields.
@ 2006-11-22 12:14 Zhichu Chen
  2006-11-22 14:03 ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Zhichu Chen @ 2006-11-22 12:14 UTC (permalink / raw)


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
----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Still have no idea about how to specify fonts in JavaScript fields.
  2006-11-22 12:14 Still have no idea about how to specify fonts in JavaScript fields Zhichu Chen
@ 2006-11-22 14:03 ` Hans Hagen
  2006-11-23  2:46   ` Zhichu Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2006-11-22 14:03 UTC (permalink / raw)


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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Still have no idea about how to specify fonts in JavaScript fields.
  2006-11-22 14:03 ` Hans Hagen
@ 2006-11-23  2:46   ` Zhichu Chen
  2006-11-23 11:42     ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Zhichu Chen @ 2006-11-23  2:46 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 994 bytes --]

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
----------------------------------------------------------------

[-- Attachment #2: demo-test.zip --]
[-- Type: application/zip, Size: 31666 bytes --]

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Still have no idea about how to specify fonts in JavaScript fields.
  2006-11-23  2:46   ` Zhichu Chen
@ 2006-11-23 11:42     ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2006-11-23 11:42 UTC (permalink / raw)


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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-23 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-22 12:14 Still have no idea about how to specify fonts in JavaScript fields Zhichu Chen
2006-11-22 14:03 ` Hans Hagen
2006-11-23  2:46   ` Zhichu Chen
2006-11-23 11:42     ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).