![](https://secure.gravatar.com/avatar/93131e1e6e2204bd13501390d768dbdc.jpg?s=120&d=mm&r=g)
Am 12.09.2008 um 16:30 schrieb Yue Wang:
Hi:
The following cases all use second run of context. So there is no font cache time. I use a new installed Windows XP SP3 on a Core 2 Duo 1.68GHz with 1GB mem machine. Only TeXWorks and ConTeXt are installed and running on the machine. I close all pre-installed software (like MSN, IE, etc.) and leave all extra memory for LuaTeX.
Only 3 big chinese font, AdobeSongStd-Light, AdobeHeitiStd-Regular, AdobeKaitiStd-Regular are loaded. However, different approaches have different runtime, here, two cases are tested (zhfonts is attached in the mail):
All times for a normal ConTeXt run (2 runs) without intermediate from a former run on a MacBook (2GB mem, 2.4 GHz).
\usetypescriptfile[zhfonts] \usetypescript[myfont] \setupbodyfont[myfont,rm,11pt] \starttext 你好 {\it 你好} {\bf 你好} \stoptext MtxRun | total runtime: 194.156
MtxRun | total runtime: 17.996
\definefontfeature[zh][mode=node, script=hang, lang=zhs] \definefontsynonym[song][AdobeSongStd-Light][features=zh] \definefont[song][song at 12pt] \definefontsynonym[hei][AdobeHeitiStd-Regular][features=zh] \definefont[hei][hei at 12pt] \definefontsynonym[kai][AdobeKaitiStd-Regular][features=zh] \definefont[kai][kai at 12pt] \starttext {\song 你好}{\hei 你好}{\kai 你好} \stoptext MtxRun | total runtime: 13.797
MtxRun | total runtime: 8.930
This also applies to file which only one big font, AdobeSongStd-Light, is used, two cases are tested:
\definefontfeature[zh][mode=node, script=hang, lang=zhs] \definefontsynonym[song][AdobeSongStd-Light][features=zh] \definefont[song][song at 12pt] \definefontsynonym[hei][AdobeHeitiStd-Regular][features=zh] \definefont[hei][hei at 12pt] \definefontsynonym[kai][AdobeKaitiStd-Regular][features=zh] \definefont[kai][kai at 12pt] \starttext {\song 你好} \stoptext MtxRun | total runtime: 5.609
MtxRun | total runtime: 4.820
\usetypescriptfile[zhfonts] \usetypescript[myfont] \setupbodyfont[myfont,rm,11pt] \starttext 你好 \stoptext MtxRun | total runtime: 135.125
MtxRun | total runtime: 16.326
If no Chinese fonts are used, three cases are tested: \usetypescriptfile[zhfonts] \usetypescript[myfont] \setupbodyfont[myfont,rm,11pt] \starttext Hello \stoptext MtxRun | total runtime: 89.938
MtxRun | total runtime: 14.940
\starttext Hello \stoptext MtxRun | total runtime: 2.594
MtxRun | total runtime: 2.902
\definefontfeature[zh][mode=node, script=hang, lang=zhs] \definefontsynonym[song][AdobeSongStd-Light][features=zh] \definefont[song][song at 12pt] \definefontsynonym[hei][AdobeHeitiStd-Regular][features=zh] \definefont[hei][hei at 12pt] \definefontsynonym[kai][AdobeKaitiStd-Regular][features=zh] \definefont[kai][kai at 12pt] \starttext Hello \stoptext MtxRun | total runtime: 2.734
MtxRun | total runtime: 2.892
In a typical chinese science book, usually 4 to 10 chinese truetype/opentype font are used. Magazines might use twenty or more. So if we want to use the standard way (use chinese font as body font, use virtual fonts mechanism to mix the font with latin fonts, use different alternatives for single chinese font) as the zhfonts.tex is presented, the running time here is usually intolerable (more than 3 minutes' loading time with very simple text for three fonts).
Enable \preloadtypescript in cont-sys.tex.
A simple XeLaTeX file with three font embeding using XeCJK or zhspacing for interchartoken font switching usually runs less than 8 seconds. In this case, all the family (rm, ss, tt) parts (like bf, it, etc) in NFSS are defined.
So, I think there should be a way to improve the font loading procedure. Maybe we had made deep copy to every fontsynonym defined here which made the loading time terribly long? Are there some way to mirror all the unchanged part of a new loading font B from a loaded time A and only leave the modified table when A and B points to same physical font? Thanks.
Yue Wang
Wolfgang