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"


\startMPenvironment[global]
    \setupbodyfont[20pt]
\stopMPenvironment

\starttext

\long\def\startstaticMPgraphic#1#2\stopstaticMPgraphic
  {\blabelgroup
   \def\MPgraphicfile{#1}% no \jobname here
   \let\MPwrite\MPstaticwrite
   \immediate\openout\MPwrite=\MPgraphicfile.mp
   \setMPrandomseedfalse
   \enableincludeMPgraphics
   \def\sometxt##1{\string\sometxt{##1}}%
   \the\everyMPgraphic
   \presetMPdefinitions
   \theMPinclusions % brrr
   \writeMPgraphic{\letterpercent mpenvironment: \the\everyMPTEXgraphic}%
   \writeMPgraphic{beginfig(1);}%
   \writeMPgraphic{#2}%
   \writeMPgraphic{endfig; end.}%
   \immediate\closeout\MPwrite
   \immediate\closeout\MPwrite
   \runMPgraphicstrue
   \executeMPgraphicfile
   \elabelgroup}

\startstaticMPfigure{fig}
  label(\sometxt{in sometxt},origin);
\stopstaticMPfigure

outside sometxt
\usestaticMPfigure[fig]
\stoptext

for this we need to patch tex.rb:

def processmpstatic
        if filename = getvariable('filename') then
            filename += ".mp" unless filename =~ /\..+?$/
            if FileTest.file?(filename) then
                begin
                    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
                            "\n"
                        end
                        f << "\\starttext\n"
                        f << "\\startMPpage\n"
                        f << data.gsub(/end\.*\s*$/m, '') # a bit of a hack
                        f << "\\stopMPpage\n"
                        f << "\\stoptext\n"
                    end
                    report("converting static '#{filename}'")
                    runtex("texexec.tex")
                    pdffile = File.suffixed(filename,'pdf')
                    File.silentrename("texexec.pdf",pdffile)
                    report ("#{filename} converted to #{pdffile}")
                rescue
                    report("error in converting #{filename} (#{$!}")
                end
            end
        end
        reportruntime
    end

but that's about it


Hans

-- 

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

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to