ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Yue Wang <yuleopen@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: XeConTeXt bug report I: strange benchmark
Date: Wed, 13 May 2009 12:38:42 +0800	[thread overview]
Message-ID: <68bfdc900905122138p440e8b0bp8dfdb847fa8a27d9@mail.gmail.com> (raw)
In-Reply-To: <4A099440.1030600@wxs.nl>

Hi, Hans:

On Tue, May 12, 2009 at 11:22 PM, Hans Hagen <pragma@wxs.nl> wrote:
> \setupbodyfont[myzhfont] \dorecurse{10000}{{hello
> {\switchtobodyfont[myzhfont] 你好}}\par}
> so it's probably also an operating system issue (caching files in mem, disk access etc)

After debugging for half an hour in the morning, finally I know why
this is so slow on both XeTeX and pdfTeX.
This problem is not an operating system issue, But a ConTeXt "feature".

in font-mkii, you use the following to define a actual font
(\definefontlocal and \definefontglobal):
  {\expandafter\xdef\csname#1\endcsname  % ! ! ! ! not needed in luatex ! ! ! !
     {\noexpand\csname#1:\endcsname
      \noexpand\reactivatefont{\somefontname}{\fontfile}}%

For example, in the previous example, it will define a lot of fonts,
like \*myzhfont12ptmmexrm*: , is defined as
\reactivatefont{cmex10}{lmex10}. When define that font, a macro
\*myzhfont12ptmmexrm* is defined to select the \*myzhfont12ptmmexrm* :
font.
\*myzhfont12ptmmexrm* =\csname *myzhfont12ptmmexrm* :\endcsname
\reactivefont{cmex10}{lmex10}
TeX then expand your reactivatefont macros to lmex10 at 12.0pt. So the
\*myzhfont12ptmmexrm*: font will assigned to lmex10 at 12.0pt. This is
quite right for definition.

However, after switching the font, the problems occurs:
it tries to call \*myzhfont12ptmmexrm* macro. the macro then expands to
\csname *myzhfont12ptmmexrm* :\endcsname \reactivefont{cmex10}{lmex10}
then to
\*myzhfont12ptmmexrm* :\reactivefont{cmex10}{lmex10}
and here TeX tries to do the following thing:
TeX select the font \*myzhfont12ptmmexrm*:, which is lmex10 at 12pt,
then *changing* into that font environment in order to *typeset*
\reactivefont.  it then expand the macro of reacitve font, but found
nothing to typeset...

what's worse, this will occur on every real fonts in the definition.
So in fact TeX will switching dozens of fonts into the *current* font
for a "\switchtobodyfont" call, in order to typeset nothing. And
that's why ConTeXt is so slow on typeface changing.

The solution to this bug (or feature?) is quite easy, just use \font
to define the \*myzhfont12ptmmexrm*: font, but pay attention not to
switch the current font to \*myzhfont12ptmmexrm*: . Since it is quite
slow to switch to dozens of font for one \switchtobodyfont call even
in Knuth TeX.




Yue Wang









> so it's probably also an operating system issue (caching files in mem, disk
> access etc)
>
> -----------------------------------------------------------------
>                                          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
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2009-05-13  4:38 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-12  5:01 Yue Wang
2009-05-12  9:02 ` Yue Wang
2009-05-12  9:09 ` Yue Wang
2009-05-12  9:30   ` Hans Hagen
2009-05-12  9:59     ` Yue Wang
2009-05-12 10:04       ` Yue Wang
2009-05-12 10:06       ` Hans Hagen
     [not found]         ` <4A094C71.3040503@elvenkind.com>
2009-05-12 11:02           ` Hans Hagen
2009-05-12 11:26             ` Taco Hoekwater
2009-05-12 11:33               ` Yue Wang
2009-05-12 11:52                 ` Taco Hoekwater
2009-05-12 11:57                   ` Hans Hagen
2009-05-12 12:01                   ` Yue Wang
2009-05-12 12:21                     ` Hans Hagen
2009-05-12 12:26                     ` Taco Hoekwater
2009-05-12 12:31                       ` Yue Wang
2009-05-12 11:09           ` Yue Wang
2009-05-12 11:37             ` Hans Hagen
2009-05-12 12:26               ` Yue Wang
2009-05-12 12:54                 ` Hans Hagen
2009-05-12 13:59                   ` Yue Wang
2009-05-12 14:11                     ` Yue Wang
2009-05-12 15:02                       ` Hans Hagen
2009-05-12 15:12                         ` Yue Wang
2009-05-12 15:22                           ` Hans Hagen
2009-05-12 15:45                             ` Yue Wang
2009-05-13  4:38                             ` Yue Wang [this message]
2009-05-13  7:49                               ` Yue Wang
2009-05-13  8:28                               ` Hans Hagen
2009-05-12 15:45                           ` Hans Hagen
2009-05-12 14:50                     ` Hans Hagen
2009-05-12 15:10                       ` Yue Wang
2009-05-12 15:14                         ` Taco Hoekwater
2009-05-12 15:41                           ` Hans Hagen
2009-05-12 15:49                             ` Yue Wang
2009-05-12 15:20                         ` Hans Hagen
2009-05-12 15:50                     ` Hans Hagen
2009-05-13  8:59       ` Mojca Miklavec
2009-05-13  9:55         ` Mojca Miklavec
2009-05-13 11:12           ` Hans Hagen
2009-05-13 11:17           ` Hans Hagen
2009-05-13 10:02         ` Wolfgang Schuster
2009-05-13 10:17           ` Mojca Miklavec
2009-05-13 10:41             ` Wolfgang Schuster
2009-05-13 11:12               ` Mojca Miklavec
2009-05-13 11:28                 ` Wolfgang Schuster
2009-05-13 12:48                   ` Thomas A. Schmitz
2009-05-13 12:26                 ` Yue Wang
2009-05-13 12:59                   ` Hans Hagen
2009-05-13 13:25                     ` Wolfgang Schuster
2009-05-12 11:01   ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68bfdc900905122138p440e8b0bp8dfdb847fa8a27d9@mail.gmail.com \
    --to=yuleopen@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).