ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: \sometxt bodyfontsize in staticMPfigure (2006.09.27 beta)
Date: Thu, 28 Sep 2006 09:25:50 +0200	[thread overview]
Message-ID: <451B78FE.2030808@wxs.nl> (raw)
In-Reply-To: <E1GSnRi-0003Yg-U2@approximate.corpus.cam.ac.uk>

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

  reply	other threads:[~2006-09-28  7:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-28  4:24 Sanjoy Mahajan
2006-09-28  7:25 ` Hans Hagen [this message]
2006-09-29  0:16   ` Sanjoy Mahajan
2006-09-29  7:12     ` Hans Hagen
2006-10-04 23:14   ` Aditya Mahajan
2006-10-05  4:38     ` Sanjoy Mahajan
2006-10-05  7:08       ` Taco Hoekwater
2006-10-05  8:01     ` Hans Hagen
2006-10-05 13:22       ` Aditya Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=451B78FE.2030808@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).