[NTG-context] \sometxt bodyfontsize in staticMPfigure (2006.09.27 beta)

Hans Hagen pragma at wxs.nl
Thu Sep 28 09:25:50 CEST 2006

Sanjoy Mahajan wrote:
> [I'm testing the 2006.09.27 beta on Linux]
> Thanks for the new \sometxt in staticMPfigures.  I'm just testing its
> operation, and find that the text is not set in the document's bodyfont
> size.  For example,
> \setupbodyfont[20pt]
> \starttext
> \startstaticMPfigure{fig}
>   label(\sometxt{in sometxt},origin);
> \stopstaticMPfigure
> outside sometxt
> \usestaticMPfigure[fig]
> \stoptext
> produces a small "in sometxt" and a large "outside sometxt".  
> With this file both are large, as I expected \sometxt to work:
> \setupbodyfont[20pt]
> \starttext
> \startreusableMPgraphic{fig}
>   label(\sometxt{in sometxt},origin);
> \stopreusableMPgraphic{
> outside sometxt
> \reuseMPgraphic{fig}
> \stoptext
> I haven't figured out the full story.  But in the intermediate .mp files
> generated by texexec, the staticMPfigure case has
> "BodyFontSize:=12.0pt;" whereas in the reusableMPgraphic case, the file
> has "BodyFontSize:=20.0pt;".
this is runtime tex into passed to the graphic ... imagine that we flush 
this to the mp file ... it can contain info that is not known in that 
session (like overlay info) which willbreak the mp run

the issue here is that a static graphic is processed in another, 
independent run, that's the whole idea behind static graphics (quick 
hack for independent graphics)

we can spend a lot of time to make it more advanced but within a year 
from now we will have mp as a library in tex which willreduce runtime to 
nearly zero (at least that 's what experiments show) so ....

what we can do is pass info from the mpenvironment"



   \def\MPgraphicfile{#1}% no \jobname here
   \theMPinclusions % brrr
   \writeMPgraphic{\letterpercent mpenvironment: \the\everyMPTEXgraphic}%
   \writeMPgraphic{endfig; end.}%

  label(\sometxt{in sometxt},origin);

outside sometxt

for this we need to patch tex.rb:

def processmpstatic
        if filename = getvariable('filename') then
            filename += ".mp" unless filename =~ /\..+?$/
            if FileTest.file?(filename) then
                    data = IO.read(filename)
                    File.open("texexec.tex",'w') do |f|
                        f << "\\setupoutput[pdftex]\n"
                        f << "\\setupcolors[state=start]\n"
                        data.sub!(/^%mpenvironment\:\s*(.*?)$/mois) do
                            f << $1
                        f << "\\starttext\n"
                        f << "\\startMPpage\n"
                        f << data.gsub(/end\.*\s*$/m, '') # a bit of a hack
                        f << "\\stopMPpage\n"
                        f << "\\stoptext\n"
                    report("converting static '#{filename}'")
                    pdffile = File.suffixed(filename,'pdf')
                    report ("#{filename} converted to #{pdffile}")
                    report("error in converting #{filename} (#{$!}")

but that's about it



                                          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

More information about the ntg-context mailing list