On Sat, 23 Jun 2007, nicola wrote:
Hi, given the following XeConTeXt document (I use ConTeXt ver: 2007.01.12):
\definetypeface[MyMainFace][rm][Xserif][Charis SIL][default][encoding=uc] \definetypeface[MyMainFace][mm][math][euler][euler] \setupbodyfont[MyMainFace,10pt]
\startuseMPgraphic{foo} for i = 0 upto 10: % Draw a label at position (i*cm,0) endfor; \stopuseMPgraphic
\starttext \midaligned{\useMPgraphic{foo}} \stoptext
is it possible to replace the comment with an instruction (or a macro), such that I do not get compilation errors and I get consistent font usage?
I have tried the following possibilities:
a) label("test",(i*cm,0)); % Complains about missing metrics for font b) label(\textext{test},(i*cm,0)); % Ditto
This is strange. Do you also get this error if you use pdftex instead of xetex?
c) label(btex test $x$ etex,(i*cm,0)); % Results in wrong font d) label(\sometxt{test},(i*cm,0)); % Ok, right font, but loop is ignored
The best option to my knowledge is \sometxt, but I have read that it cannot be used in loops. Before I start unrolling all the loops in my figures
1) is it possible to specify the fonts in an MPenviroment? If so, how?
Just as you will specify fonts in your regular document. The easiest way is as follows: Place \startMPinclusions[global] .. \stopMPinclusions around the font definitions in your document. That way, the same fonts will be used in your document and in metapost. But I have never tested this with xetex. In priciple, this should work (as long as texexec calls metapost with tex=xetex).
2) is there some hack, maybe along the lines of the following (not working) example?
vardef prepare(expr n) = save s; string s; s = ""; for i = 0 upto n-1: s := s & "label(\sometxt{test},(" & decimal(i) & "*cm,0));"; endfor; s enddef; scantokens(prepare(10));
Have you checked \startTeXtexts ...\stopTeXtexts? See Section 4.4 of Mojca's MyWay on \sometxt (http://dl.contextgarden.net/myway/sometxt.pdf) Aditya