I'm trying to make a package for easy font switching for XeTeX. The command that loads such fonts, would automatically try to substitute the missing font (like slanted fonts), and try to guess the font type, and set all the definitions that were defined by default for Computer Modern font. I have an attempt for that, but I clearly remember, that that does not takes too much time to compile.

Now I'm trying to remake with a different approach, that compiling it by it self takes too much time. I'm not certain of the proper use of \newtoks, but I use that to store the name of the font, so whenever I slightly change for instance the font size, I can apply it by only reissue an apply command. Is that possible, that such tokens takes up to ~5-10 second? Or MikTeX have completely wrong setup for XeTeX?


After some debugging, I figured out, that the slower part is for loading Computer Modern font again. Someone asked me to share the code, however, now that I know where is the problem, I only share the necessary part of the code. (Not that if it would be a secret. I shared a link to the code) Slow part is marked with the text "Ridiculously slow, no matter what".

% Define tokens for fontfaces
\newtoks\biface  % Bold italic
\newtoks\bsface  % Bold slanted
% Technically impossible to create MORE slanted (slanted) italic font, or
% slanted bold slanted italic.

% I slightly modified the Typewriter Type, so it can be used, with \rm \it etc.
% Although its still be available with \tt.


\newtoks\mrmface % Math roman (for Ms font set)
\newtoks\mitface % Math italic
\newtoks\msyface % Math symbols
\newtoks\mexface % Math extended
\newtoks\calface % Caligraphic face (Restored to default if empty)
\newtoks\setface % Caligraphic face (Removed/Ignored if empty)
\let\omathbb=\relax % Temporary placement of \mathbb, if defined.








% Defining main font faces
\font\trm="\the\rmface" at \fontsize%
\font\osy="\the\rmface:+onum" at \fontsize%
\font\tit="\the\rmface:slant=.2" at \fontsize%
\font\sit="\the\rmface:slant=.2" at .7\fontsize%
\font\fit="\the\rmface:slant=.2" at .5\fontsize%
\font\tit="\the\itface" at \fontsize%
\font\sit="\the\itface" at .7\fontsize% Ridiculously slow, no matter what.
\font\fit="\the\itface" at .5\fontsize%
\font\tsl="\the\rmface:slant=.167" at \fontsize%
\font\ssl="\the\rmface:slant=.167" at .7\fontsize%
\font\fsl="\the\rmface:slant=.167" at .5\fontsize%
\font\tsl="\the\slface" at \fontsize%
\font\ssl="\the\slface" at .7\fontsize%
\font\fsl="\the\slface" at .5\fontsize%
\font\tbf="\the\rmface:embolden=3" at \fontsize%
\font\sbf="\the\rmface:embolden=3" at .7\fontsize%
\font\fbf="\the\rmface:embolden=3" at .5\fontsize%
\font\tbf="\the\bfface" at \fontsize%
\font\sbf="\the\bfface" at .7\fontsize%
\font\fbf="\the\bfface" at .5\fontsize%
\if&\the\biface&\if&\the\itface&\font\tbi="\the\rmface:embolden=3:slant=.2" at \fontsize%
\else\font\tbi="\the\itface:embolden=3" at \fontsize\fi%
\else\font\tbi="\the\biface" at \fontsize\fi%
\if&\the\bsface&\if&\the\bfface&\font\tbs="\the\rmface:embolden=3:slant=.167" at \fontsize%
\else\font\tbs="\the\bfface:slant=.167" at \fontsize\fi%
\else\font\tbs="\the\bsface" at \fontsize\fi%
\font\ttt="\the\ttface" at \fontsize%
\font\stt="\the\ttface" at .7\fontsize%
\font\ftt="\the\ttface" at .5\fontsize%
% Math font face definitions
\font\mtrm="\the\rmface" at \fontsize%
\font\msrm="\the\rmface" at .7\fontsize%
\font\mfrm="\the\rmface" at .5\fontsize%
\ifnum\XeTeXfonttype\mtrm=0\let\mosy=\relax\else\font\mosy="\the\rmface:+onum" at \fontsize\fi%
\font\mtrm="\the\mrmface" at \fontsize%
\font\msrm="\the\mrmface" at .7\fontsize%
\font\mfrm="\the\mrmface" at .5\fontsize%
\ifnum\XeTeXfonttype\mtrm=0\let\mosy=\relax\else\font\mosy="\the\mrmface:+onum" at \fontsize\fi%
\font\mtit="\the\itface" at \fontsize%
\font\msit="\the\itface" at .7\fontsize%
\font\mfit="\the\itface" at .5\fontsize%
\font\mtit="\the\mitface" at \fontsize%
\font\msit="\the\mitface" at .7\fontsize%
\font\mfit="\the\mitface" at .5\fontsize%
\font\mtsy="\the\msyface" at \fontsize%
\font\mssy="\the\msyface" at .7\fontsize%
\font\mfsy="\the\msyface" at .5\fontsize%
\font\mtex="\the\mexface" at \fontsize%
\font\msex="\the\mexface" at .7\fontsize%
\font\mfex="\the\mexface" at .5\fontsize%
\font\tcal="\the\calface" at \fontsize%
\font\scal="\the\calface" at .7\fontsize%
\font\fcal="\the\calface" at .5\fontsize%
\font\tset="\the\setface" at \fontsize%
\font\sset="\the\setface" at .7\fontsize%
\font\fset="\the\setface" at .5\fontsize%
% Family setup

(The code above follow the procession order, and not how it appears in the file)
The interesting part, that no matter what I removed, the next line that stood in its place become slow, so it may be independent from what is on that line.

  • 1
    I think some example code might help out here!
    – Joseph Wright
    Sep 19, 2010 at 8:51
  • You're right! Here is the problematic file: http [colon] [slash] [slash] people [dot] inf [dot] elte [dot] hu/juadaml/bin/new.xetex.part2.tex But you're not going to be able to use it without this: http [colon] [slash] [slash] people [dot] inf [dot] elte [dot] hu/juadaml/bin/new.xetex.part1.tex Although they not quite finished, and they are not in they final form.
    – Adam L. S.
    Sep 19, 2010 at 21:58

1 Answer 1


No, from your description I doubt it's the fault of using token registers. You're not calling \newtoks every time, though, right?

Are you writing your package for plain xetex? Sounds like a fair amount of overlap with the fontspec package, otherwise.

  • Of course I not call \newtoks all the time. Only once at the beginning of the file. Yes, I'm writing this "package" for plain XeTeX. Although I don't really know what makes a TeX file a package, so it might an overstatement for my attempts. Thanks tough!
    – Adam L. S.
    Sep 19, 2010 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .