Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

Edit

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\rmface
\newtoks\itface
\newtoks\slface
\newtoks\bfface
\newtoks\biface  % Bold italic
\newtoks\bsface  % Bold slanted
% Technically impossible to create MORE slanted (slanted) italic font, or
% slanted bold slanted italic.
\newtoks\ttface

% I slightly modified the Typewriter Type, so it can be used, with \rm \it etc.
% Although its still be available with \tt.
\newtoks\ttrmface
\newtoks\ttitface
\newtoks\ttslface
\newtoks\ttbfface
\newtoks\ttbiface
\newtoks\ttbsface

\newtoks\titleface
\newtoks\titleitface
\newtoks\titleslface
\newtoks\titlebfface
\newtoks\titlebiface
\newtoks\titlebsface

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

[...]

\rmface={cmr10}
\itface={cmr10}
\slface={cmsl10}
\bfface={cmbx10}
\biface={cmbxti10}
\bsface={cmbxsl10}

\titleface={cmss10}
\titleitface={cmssi10}
\titleslface={cmssi10}
\titlebfface={cmssdc10}
\titlebiface={cmssbx10}
\titlebsface={cmssqi8}

\ttface={cmtt10}
\ttrmface={cmtt10}
\ttitface={cmitt10}
\ttslface={cmsltt10}
\ttbfface={cmtt10}
\ttbiface={cmitt10}
\ttbsface={cmsltt10}

\mrmface={cmr10}
\mitface={cmmi10}
\msyface={cmsy10}
\mexface={cmex10}
\calface={}
\setface={}

\fontsize=10pt
\count\footins=830
\titlesize={3}
\hasize={1.5}
\hbsize={1.17}
\hcsize={1.17}
\hdsize={1}
\hesize={1}
\hfsize={.85}
\hgsize={.85}
\hhsize={.85}
\hisize={.85}

[...]

% Defining main font faces
\font\trm="\the\rmface" at \fontsize%
\ifnum\XeTeXfonttype\trm=0\def\oldstyle{\fam1\tit}\else%
\font\osy="\the\rmface:+onum" at \fontsize%
\def\oldstyle{\fam8\osy}\fi%
\if&\the\itface&%
\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%
\else%
\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%
\fi%
\if&\the\slface&%
\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%
\else%
\font\tsl="\the\slface" at \fontsize%
\font\ssl="\the\slface" at .7\fontsize%
\font\fsl="\the\slface" at .5\fontsize%
\fi%
\if&\the\bfface&%
\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%
\else%
\font\tbf="\the\bfface" at \fontsize%
\font\sbf="\the\bfface" at .7\fontsize%
\font\fbf="\the\bfface" at .5\fontsize%
\fi%
\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%
\if&\the\ttface&%
\else%
\font\ttt="\the\ttface" at \fontsize%
\font\stt="\the\ttface" at .7\fontsize%
\font\ftt="\the\ttface" at .5\fontsize%
\fi%
% Math font face definitions
\if&\the\mrmface&%
\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%
\else%
\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%
\fi%
\if&\the\mitface&%
\font\mtit="\the\itface" at \fontsize%
\font\msit="\the\itface" at .7\fontsize%
\font\mfit="\the\itface" at .5\fontsize%
\else%
\font\mtit="\the\mitface" at \fontsize%
\font\msit="\the\mitface" at .7\fontsize%
\font\mfit="\the\mitface" at .5\fontsize%
\fi%
\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%
\if&\the\calface&%
\def\cal{\fam2}%
\else%
\font\tcal="\the\calface" at \fontsize%
\font\scal="\the\calface" at .7\fontsize%
\font\fcal="\the\calface" at .5\fontsize%
\textfont9=\tcal\scriptfont9=\scal\scriptscriptfont9=\fcal%
\def\cal{\fam9\tcal}%
\fi%
\if&\the\setface&%
\ifx\omathbb\relax\let\mathbb=\relax\else\let\mathbb=\omathbb\let\omathbb=\relax\fi%
\else%
\font\tset="\the\setface" at \fontsize%
\font\sset="\the\setface" at .7\fontsize%
\font\fset="\the\setface" at .5\fontsize%
\textfont10=\tset\scriptfont10=\sset\scriptscriptfont10=\fset%
\ifx\omathbb\relax\ifx\mathbb\relax\else\let\omathbb=\mathbb\fi\fi%
\def\mathbb####1{{\fam10\tset####1}}%
\fi%
% Family setup
\textfont0=\mtrm\scriptfont0=\msrm\scriptscriptfont0=\mfrm%
\textfont1=\mtit\scriptfont1=\msit\scriptscriptfont1=\mfit%
\textfont2=\mtsy\scriptfont2=\mssy\scriptscriptfont2=\mfsy%
\textfont3=\mtex\scriptfont3=\msex\scriptscriptfont3=\mfex%
\textfont4=\tit\scriptfont4=\sit\scriptscriptfont4=\fit%
\textfont5=\tsl\scriptfont5=\ssl\scriptscriptfont5=\fsl%
\textfont6=\tbf\scriptfont6=\sbf\scriptscriptfont6=\fbf%
\textfont7=\ttt\scriptfont7=\stt\scriptscriptfont7=\ftt%
\ifx\mosy\relax\else\textfont8=\mosy\scriptfont8=\mosy\scriptscriptfont8=\mosy\fi%
%
\rm%
\initrmfam%
\inititfam%
\initsyfam%
\initexfam%

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

share|improve this question
1  
I think some example code might help out here! –  Joseph Wright Sep 19 '10 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 '10 at 21:58

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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 '10 at 21:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.