ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* setting size of page headers
@ 2000-11-17 19:57 siepo
  2000-11-19 15:28 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: siepo @ 2000-11-17 19:57 UTC (permalink / raw)


I need a parameterized way to set the font size of page headers, with an
explicit fontsize as parameter. The following works:

\getparameters[demo][numsize=8pt]
\xdef\foliofnt{\switchtobodyfont [\demonumsize]}
\setupheader[style=\foliofnt]

However, this causes a noticable performance hit compared to e.g.

\setupheader[style=small]

Is there a way around this?

Siep


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

* Re: setting size of page headers
  2000-11-17 19:57 setting size of page headers siepo
@ 2000-11-19 15:28 ` Hans Hagen
  2000-11-20 22:52   ` siepo
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2000-11-19 15:28 UTC (permalink / raw)
  Cc: ntg-context

At 08:57 PM 11/17/00 +0100, siepo@client44-3.kabelA.oprit.rug.nl wrote:
>I need a parameterized way to set the font size of page headers, with an
>explicit fontsize as parameter. The following works:
>
>\getparameters[demo][numsize=8pt]
>\xdef\foliofnt{\switchtobodyfont [\demonumsize]}
>\setupheader[style=\foliofnt]
>
>However, this causes a noticable performance hit compared to e.g.
>
>\setupheader[style=small]
>
>Is there a way around this?

I assume that you want to do this in order to speed up processing. 

\switchtobodyfont is slow due the fact that quite some related font info
has to be switched [esp math]. In the case of headers and footers and
alike, there is a switch for each header part, so the more you have
defined, the slower the process. This is why you can set the style for all
layout areas at once, 

  \setuplayout[style={\switchtobodyfont[10pt}]

This is significant faster. BTW, your \xdef is okay in etex, but normally
edef/xdef can be tricky in combination with commands that themselves do
\edef's and alike. In non etex you can prefix the switch with \noexpand.
Also, in this case i suppose that a \gdef would work as well. 

This leaves the difference between style=small and
style={\switchtobodyfont[small]}. A small style is just \tfx, so a small
size of the current text font, and since there are no other swithches
involved it is much faster then a complete bodyfont switch. 

If you know that there is no math, and you know the font, you can do [fast]
things like: 

\definefont[foliofont][Regular at \numsize]

\setupheader[style=foliofont]

if you know what goes left/right you can save a bit by leftstyle=foliofont  

Hans
-------------------------------------------------------------------------
                                                  Hans Hagen | PRAGMA ADE
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

* Re: setting size of page headers
  2000-11-19 15:28 ` Hans Hagen
@ 2000-11-20 22:52   ` siepo
  0 siblings, 0 replies; 3+ messages in thread
From: siepo @ 2000-11-20 22:52 UTC (permalink / raw)
  Cc: ntg-context

On 19 Nov, Hans Hagen wrote:
> At 08:57 PM 11/17/00 +0100, siepo@client44-3.kabelA.oprit.rug.nl wrote:
>>I need a parameterized way to set the font size of page headers, with
>>an explicit fontsize as parameter. The following works:
>>
>>\getparameters[demo][numsize=8pt]
>>\xdef\foliofnt{\switchtobodyfont [\demonumsize]}
>>\setupheader[style=\foliofnt]
>>
>>However, this causes a noticable performance hit compared to e.g.
>>
>>\setupheader[style=small]
>>
>>Is there a way around this?
> 
> I assume that you want to do this in order to speed up processing. 
> 
> \switchtobodyfont is slow due the fact that quite some related font
> info has to be switched [esp math]. In the case of headers and footers
> and alike, there is a switch for each header part, so the more you
> have defined, the slower the process. This is why you can set the
> style for all layout areas at once,
> 
>   \setuplayout[style={\switchtobodyfont[10pt}]
> 
> This is significant faster. BTW, your \xdef is okay in etex, but
> normally edef/xdef can be tricky in combination with commands that
> themselves do
> \edef's and alike. In non etex you can prefix the switch with
> \noexpand. Also, in this case i suppose that a \gdef would work as
> well.

\gdef worked indeed ok.

> This leaves the difference between style=small and
> style={\switchtobodyfont[small]}. A small style is just \tfx, so a
> small size of the current text font, and since there are no other
> swithches involved it is much faster then a complete bodyfont switch.
> 
> If you know that there is no math, and you know the font, you can do
> [fast] things like:
> 
> \definefont[foliofont][Regular at \numsize]
> 
> \setupheader[style=foliofont]
> 
> if you know what goes left/right you can save a bit by
> leftstyle=foliofont
> 
> Hans

There is no guarantee that there is no math. There is no guarantee
either that page numbers and page headers have the same fontsize. But it
might be a good idea to use \setupheader[style=...] for the text headers
and a fast font switch for the page numbers:

\getparameters[demo][pheadsize=6pt,numsize=14pt]
\gdef\pheadfont{\switchtobodyfont [\demopheadsize]}
\definefont[foliofont][Regular at \demonumsize]
\setuplayout[headerdistance=60pt,style=\pheadfont]
\setupheadertexts
 [\foliofont\pagenumber][left][right][\foliofont\pagenumber]

This is noticeably faster than it was, and consistent with the desired
interface.

Siep


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

end of thread, other threads:[~2000-11-20 22:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-17 19:57 setting size of page headers siepo
2000-11-19 15:28 ` Hans Hagen
2000-11-20 22:52   ` siepo

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