Provare mplib in luatex

  • Creatore
    Topic
  • #40881
    robitex
    Amministratore del forum
      Up
      0
      Down
      ::


      Sapendo che luatex include METAPOST sottoforma di libreria chiamata mplib, ho voluto provare questo semplice codice:`
      \directlua{
      local mpcode, mp, mpfig

      mpcode = [[
      beginfig(1);
      draw (0,0)–(100,100) withcolor 0.765red;
      endfig;
      ]]

      mp = mplib.new()
      mpfig = mp:execute(mpcode)
      mp:finish()

      tex.print(mpfig.log);
      }
      \end
      `

      Alla linea di comando ottengo (test compiuto sotto TeX Live 2009 in Windows):
      `>luatex ee.tex
      This is LuaTeX, Version beta-0.40.6-2009110118 (Web2C 2009)
      (ee.tex [1{c:/Programmi/texlive/2009/texmf-var/fonts/map/pdftex/updmap/pdftex.m
      ap}] )
      Output written on ee.pdf (1 page, 24060 bytes).
      Transcript written on ee.log.
      >Exit code: 0`

      Aprendo il pdf posso leggere il log che è questo:
      `This is MetaPost, Version 1.208 (INIMP) 8 JAN 2010 09:28
      >> beginfig(1)
      ! Isolated expression.

      ;
      <*> beginfig(1);
      draw (0,0){(100,100) withcolor 0.765red; endfig;
      I couldn't nd an
      `=' or `:=' after the
      expression that is shown above this error message,
      so I guess I'll just ignore it and
      carry on.

      >> draw(0
      ! Isolated expression.

      ,
      <*> beginfig(1); draw (0, 0){(100,100)
      withcolor 0.765red; endfig;
      I couldn't nd an `=' or `:=' after the
      expression that is shown above this error
      message,
      so I guess I'll just ignore it and carry on.

      ! Extra tokens will be ushed.

      ,
      <*> beginfig(1); draw (0, 0){(100,100) withcolor 0.765red; endfig;
      I've just read as much of that
      statement as I could fathom,
      so a semicolon should have been next. It's very puzzling…
      but I'll try to get
      myself back together, by ignoring
      everything up to the next `;'. Please insert a semicolon
      now in front of anything that you don't want me to delete.
      (See Chapter 27 of The METAFONTbook for an example.)

      >>endfig
      ! Isolated expression.

      ;
      <*> …0,0){(100,100) withcolor 0.765red; endfig;

      I couldn't find an `=' or `:=' after the
      expression that is shown above this error message,
      so I guess I'll just
      ignore it and carry on.
      `

      I miei tentativi di ritrovare il disegno nel pdf finale non sono andati a buon fine, allora sono ricorso alla stampa del log.
      Evidentemente la libreria viene caricata ma nell’esecuzione si incontra un problema che non riesco a districare.
      Ho provato ad assegnare la codifica unicode al sorgente e a cambiare il carattere di ritorno a capo, ma senza che questo influenzi il log.

      Grazie per aver seguito fin quì.

    Visualizzazione 5 filoni di risposte
    • Autore
      Risposte
      • #40882
        Up
        0
        Down
        ::


        Conviene che installi una minimals-beta e guardi sotto
        minimals-beta/tex/texmf-context/tex/generic/context

        Genera il formato con
        #>luatex –ini luatex-plain.tex

        correggi la linea 323 di luatex-mplib.lua in
        local fignum = tonumber(match(figure:filename(),”([%d]+)$”) or figure:charcode() or 0)

        e dopo prova
        `
        \pdfoutput=1
        \setmplibformat{plain}

        \mplibcode
        beginfig(1) ;
        draw fullcircle
        scaled 10cm
        withcolor red
        withpen pencircle xscaled 4mm yscaled 2mm rotated 30 ;
        endfig ;
        \endmplibcode
        \end
        `

        NB: mplib in luatex non è ancora equivalente a mpost.
        In mkiv è molto meglio, anche se credo che prescript e postscript non siano gestiti completamente

      • #40883
        robitex
        Amministratore del forum
          Up
          0
          Down
          ::

          Conviene che installi una minimals-beta e guardi sotto
          minimals-beta/tex/texmf-context/tex/generic/context

          Genera il formato con
          #>luatex –ini luatex-plain.tex

          correggi la linea 323 di luatex-mplib.lua in
          local fignum = tonumber(match(figure:filename(),”([%d]+)$”) or figure:charcode() or 0)

          e dopo prova
          `
          \pdfoutput=1
          \setmplibformat{plain}

          \mplibcode
          beginfig(1) ;
          draw fullcircle
          scaled 10cm
          withcolor red
          withpen pencircle xscaled 4mm yscaled 2mm rotated 30 ;
          endfig ;
          \endmplibcode
          \end
          `

          NB: mplib in luatex non è ancora equivalente a mpost.
          In mkiv è molto meglio, anche se credo che prescript e postscript non siano gestiti completamente

          Grazie Luigi, spiegazione molto chiara.
          Aggiungerò a questo post i risultati dell’esperimento se avrò tempo di installare la minimals.
          Grazie ancora.

        • #40884
          robitex
          Amministratore del forum
            Up
            0
            Down
            ::


            Ok, problemi di convivenza.
            Ho installato tramite lo script first-setup.sh la minimals in Ubuntu 8.04 dove risiede già una TeX Live 2009 (derivata dalla Pretesting).

            Poi ho generato il formato e successivamente compilato il sorgente di test ma ottengo un errore dovuto ad una differenza di formati.
            In pratica genero il formato con luatex v. 0.50 ma kpathsea trova le dir della texlive 2009 e in qualche modo va in conflitto con luatex 0.40 del ramo tl 2009.

            Ho provato vari script ma non ho risolto.
            Come posso fare?
            Ecco la sessione di lavoro completa:
            `roberto@pc-studio:~$ cd ~/context/tex/texmf-linux/bin
            roberto@pc-studio:~/context/tex/texmf-linux/bin$ ./luatex –ini ~/context/tex/texmf-context/tex/generic/context/luatex-plain.tex
            This is LuaTeX, Version beta-0.50.0-2009122419 (INITEX)
            \write18 enabled.
            (/home/roberto/context/tex/texmf-context/tex/generic/context/luatex-plain.tex
            (/home/roberto/context/tex/texmf/tex/plain/base/plain.tex
            Preloading the plain format: codes, registers, parameters, fonts, more fonts,
            macros, math definitions, output routines, hyphenation
            (/home/roberto/context/tex/texmf/tex/generic/hyphen/hyphen.tex)) )
            Beginning to dump on file luatex-plain.fmt
            (format=luatex-plain 2010.1.8)
            2615 strings using 7186 bytes
            32299 memory locations dumped; current usage is 102&5146
            1412 multiletter control sequences
            \font\nullfont=nullfont
            \font\tenrm=cmr10
            \font\preloaded=cmr9
            \font\preloaded=cmr8
            \font\sevenrm=cmr7
            \font\preloaded=cmr6
            \font\fiverm=cmr5
            \font\teni=cmmi10
            \font\preloaded=cmmi9
            \font\preloaded=cmmi8
            \font\seveni=cmmi7
            \font\preloaded=cmmi6
            \font\fivei=cmmi5
            \font\tensy=cmsy10
            \font\preloaded=cmsy9
            \font\preloaded=cmsy8
            \font\sevensy=cmsy7
            \font\preloaded=cmsy6
            \font\fivesy=cmsy5
            \font\tenex=cmex10
            \font\preloaded=cmss10
            \font\preloaded=cmssq8
            \font\preloaded=cmssi10
            \font\preloaded=cmssqi8
            \font\tenbf=cmbx10
            \font\preloaded=cmbx9
            \font\preloaded=cmbx8
            \font\sevenbf=cmbx7
            \font\preloaded=cmbx6
            \font\fivebf=cmbx5
            \font\tentt=cmtt10
            \font\preloaded=cmtt9
            \font\preloaded=cmtt8
            \font\preloaded=cmsltt10
            \font\tensl=cmsl10
            \font\preloaded=cmsl9
            \font\preloaded=cmsl8
            \font\tenit=cmti10
            \font\preloaded=cmti9
            \font\preloaded=cmti8
            \font\preloaded=cmti7
            \font\preloaded=cmu10
            \font\preloaded=cmmib10
            \font\preloaded=cmbsy10
            \font\preloaded=cmcsc10
            \font\preloaded=cmssbx10
            \font\preloaded=cmdunh10
            \font\preloaded=cmr7 at 14.51799pt
            \font\preloaded=cmtt10 at 14.4pt
            \font\preloaded=cmssbx10 at 14.4pt
            \font\preloaded=manfnt
            50 preloaded fonts
            0 words of pdf memory
            0 indirect objects
            No pages of output.
            Transcript written on luatex-plain.log.

            roberto@pc-studio:~/context/tex/texmf-linux/bin$ ./luatex testmp.tex
            This is LuaTeX, Version beta-0.50.0-2009122419
            \write18 enabled.

            kpathsea: Running mktexfmt luatex.fmt
            fmtutil: running `luatex -ini -jobname=luatex -progname=luatex luatex.ini' …
            This is LuaTeX, Version beta-0.40.6-2009100220 (TeX Live 2009) (INITEX)
            (/usr/local/texlive/2009/texmf-dist/tex/plain/config/luatex.ini
            (/usr/local/texlive/2009/texmf/tex/generic/config/luatexiniconfig.tex)
            (/usr/local/texlive/2009/texmf/tex/generic/config/pdftexconfig.tex)
            (/usr/local/texlive/2009/texmf-dist/tex/plain/config/etex.ini
            (/usr/local/texlive/2009/texmf-dist/tex/plain/etex/etex.src
            (/usr/local/texlive/2009/texmf-dist/tex/plain/base/plain.tex
            Preloading the plain format: codes, registers, parameters, fonts, more fonts,
            macros, math definitions, output routines, hyphenation
            (/usr/local/texlive/2009/texmf/tex/generic/hyphen/hyphen.tex
            [skipping from \patterns to end-of-file…]))
            (/usr/local/texlive/2009/texmf-dist/tex/plain/etex/etexdefs.lib
            Skipping module “grouptypes”; Loading module “interactionmodes”;
            Skipping module “nodetypes”; Skipping module “iftypes”;)
            (/usr/local/texlive/2009/texmf-var/tex/generic/config/language.def
            (/usr/local/texlive/2009/texmf/tex/generic/hyphen/hyphen.tex)
            (/usr/local/texlive/2009/texmf-dist/tex/generic/dehyph-exptl/dehypht-x-2009-06-
            19.tex Using a TeX engine with native UTF-8 support.
            (/usr/local/texlive/2009/texmf-dist/tex/generic/dehyph-exptl/dehypht-x-2009-06-
            19.pat
            German Hyphenation Patterns (Traditional Orthography) `dehypht-x' 2009-06-19 (W
            L)))
            (/usr/local/texlive/2009/texmf-dist/tex/generic/dehyph-exptl/dehypht-x-2009-06-
            19.tex Using a TeX engine with native UTF-8 support.
            (/usr/local/texlive/2009/texmf-dist/tex/generic/dehyph-exptl/dehypht-x-2009-06-
            19.pat
            German Hyphenation Patterns (Traditional Orthography) `dehypht-x' 2009-06-19 (W
            L)))


            ecc

            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-es.
            tex UTF-8 Spanish Hyphenation Patterns
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/patterns/hyph-es.tex)
            )
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-en-
            gb.tex ASCII Hyphenation Patterns for British English
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/patterns/hyph-en-gb.t
            ex))
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-en-
            gb.tex ASCII Hyphenation Patterns for British English
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/patterns/hyph-en-gb.t
            ex))
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-en-
            gb.tex ASCII Hyphenation Patterns for British English
            (/usr/local/texlive/2009/texmf-dist/tex/generic/hyph-utf8/patterns/hyph-en-gb.t
            ex))) Augmenting the Plain TeX definitions: \tracingall;
            Adding new e-TeX definitions: \eTeX, \loggingall, \tracingnone,
            register allocation; extended register allocation;
            Recycling: \addlanguage, \@nswer (not defined), \@sk, \b@dresponsetrue,
            \b@dresponsefalse, \ch@ckforyn, \mayber@cycle, \et@xabort, \et@xbuf,
            \et@xfmtsrc, \et@xfilehdr, \et@xinf, \et@xpatterns, \l@ngdefnfile, \n@xt,
            \p@rse (not defined), \pr@mpt (not defined), \pr@mptloop (not defined),
            \forcer@cycle, \usef@llback, \usef@llbacktrue, \usef@llbackfalse,
            Retaining: \et@xerr, \et@xinput, \et@xlibhdr, \et@xmsg, \et@xtoks, \et@xwarn,
            \et@xl@@d, \et@xl@ad, \et@xload, \et@xlang, \et@xhash, \eTeX, \etexhdrchk,
            \etexstatus, \module, \uselanguage, \r@tain, \r@cycle,) ) )
            Beginning to dump on file luatex.fmt
            (format=luatex 2010.1.8)
            4549 strings of total length 74984
            101397 memory locations dumped; current usage is 108&7977
            1828 multiletter control sequences
            \font\nullfont=nullfont
            \font\tenrm=cmr10
            \font\preloaded=cmr9
            \font\preloaded=cmr8
            \font\sevenrm=cmr7
            \font\preloaded=cmr6
            \font\fiverm=cmr5
            \font\teni=cmmi10
            \font\preloaded=cmmi9
            \font\preloaded=cmmi8
            \font\seveni=cmmi7
            \font\preloaded=cmmi6
            \font\fivei=cmmi5
            \font\tensy=cmsy10
            \font\preloaded=cmsy9
            \font\preloaded=cmsy8
            \font\sevensy=cmsy7
            \font\preloaded=cmsy6
            \font\fivesy=cmsy5
            \font\tenex=cmex10
            \font\preloaded=cmss10
            \font\preloaded=cmssq8
            \font\preloaded=cmssi10
            \font\preloaded=cmssqi8
            \font\tenbf=cmbx10
            \font\preloaded=cmbx9
            \font\preloaded=cmbx8
            \font\sevenbf=cmbx7
            \font\preloaded=cmbx6
            \font\fivebf=cmbx5
            \font\tentt=cmtt10
            \font\preloaded=cmtt9
            \font\preloaded=cmtt8
            \font\preloaded=cmsltt10
            \font\tensl=cmsl10
            \font\preloaded=cmsl9
            \font\preloaded=cmsl8
            \font\tenit=cmti10
            \font\preloaded=cmti9
            \font\preloaded=cmti8
            \font\preloaded=cmti7
            \font\preloaded=cmu10
            \font\preloaded=cmmib10
            \font\preloaded=cmbsy10
            \font\preloaded=cmcsc10
            \font\preloaded=cmssbx10
            \font\preloaded=cmdunh10
            \font\preloaded=cmr7 at 14.51799pt
            \font\preloaded=cmtt10 at 14.4pt
            \font\preloaded=cmssbx10 at 14.4pt
            \font\preloaded=manfnt
            50 preloaded fonts
            0 words of pdf memory
            0 indirect objects
            No pages of output.
            Transcript written on luatex.log.
            fmtutil: /home/roberto/.texlive2009/texmf-var/web2c/luatex/luatex.fmt installed.

            —! luatex.fmt was written by a different version
            (Fatal format file error; I'm stymied)roberto@pc-studio:~/context/tex/texmf-linux/bin$
            `
            Ciao.

          • #40885
            mlgdominici
            Amministratore del forum
              Up
              0
              Down
              ::


              Ciao Roberto,

              se ricordo bene, prima di lavorare con le minimals bisogna impostare le variabili di ambiente “giuste”. Questo va fatto ogni volta con il comando

              `
              source ~/context/tex/setuptex
              `

              Naturalmente i nuovi valori delle variabili d’ambiente scompaiono una volta chiusa la shell.

              Luigi probabilmente potrà essere più preciso.

              Max.

            • #40886
              robitex
              Amministratore del forum
                Up
                0
                Down
                ::

                Ciao Roberto,

                se ricordo bene, prima di lavorare con le minimals bisogna impostare le variabili di ambiente “giuste”. Questo va fatto ogni volta con il comando

                `
                source ~/context/tex/setuptex
                `

                Naturalmente i nuovi valori delle variabili d’ambiente scompaiono una volta chiusa la shell.

                Luigi probabilmente potrà essere più preciso.

                Max.

                Purtroppo il comando source non risolve in quanto ottengo:`roberto@pc-studio:~/context/tex/texmf-linux/bin$ ./luatex testmp.tex This is LuaTeX, Version beta-0.50.0-2009122419
                \write18 enabled.

                kpathsea: Running mktexfmt luatex.fmt
                /usr/local/bin/mktexfmt: 983: /home/roberto/context/tex/texmf/texconfig/tcfmgr: not found
                fmtutil: config file `fmtutil.cnf' not found.
                I can't find the format file `luatex.fmt'!
                roberto@pc-studio:~/context/tex/texmf-linux/bin$
                `

                dopo aver creato il formato, compilando successivamente il sorgente di test.
                Grazie e ciao max.

              • #40887
                Up
                0
                Down
                ::

                Ok, problemi di convivenza.
                Ho installato tramite lo script first-setup.sh la minimals in Ubuntu 8.04 dove risiede già una TeX Live 2009 (derivata dalla Pretesting).

                Quick fix, supponendo permessi , rete etc

                1) cancella tutto e re-installa la texlive2009 dove vuoi ma non in /opt/luatex/minimals-beta

                Apri una nuova shell
                2) mkdir -p /opt/luatex/minimals-beta; cp first-setup.sh /opt/luatex/minimals-beta;
                cd /opt/luatex/minimals-beta; ./first-setup.sh

                Ad installazione finita
                3) cd tex; . setuptex

                Ora dovresti avere tutto ok

                In breve: la texlive sta per conto suo: usa il context mkii se vuoi , ma non luatex
                e mkiv perchè sono già vecchi.

                Il miglior modo per usare luatex e mkiv è minimals, ed è bene che sia completamente separato dalla texlive.

            Visualizzazione 5 filoni di risposte
            • Devi essere connesso per rispondere a questo topic.

            Go to top