diff options
Diffstat (limited to 'metapost')
| -rw-r--r-- | metapost/context/base/mp-bare.mpiv | 93 | ||||
| -rw-r--r-- | metapost/context/base/mp-mlib.mpiv | 68 | 
2 files changed, 94 insertions, 67 deletions
| diff --git a/metapost/context/base/mp-bare.mpiv b/metapost/context/base/mp-bare.mpiv new file mode 100644 index 000000000..c6194b1ee --- /dev/null +++ b/metapost/context/base/mp-bare.mpiv @@ -0,0 +1,93 @@ +%D \module +%D   [       file=mp-bare.mpiv, +%D        version=2014.10.31, +%D          title=\CONTEXT\ \METAPOST\ graphics, +%D       subtitle=plain plugins, +%D         author=Hans Hagen, +%D           date=\currentdate, +%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See licen-en.pdf for +%C details. + +if known context_bare : endinput ; fi ; +boolean context_bare  ; context_bare := true ; + +numeric mfun_tt_w[], mfun_tt_h[], mfun_tt_d[] ; +numeric mfun_tt_n ; mfun_tt_n := 0 ; +picture mfun_tt_p ; mfun_tt_p := nullpicture ; +picture mfun_tt_o ; mfun_tt_o := nullpicture ; +picture mfun_tt_c ; mfun_tt_c := nullpicture ; + +if unknown mfun_trial_run : +    boolean mfun_trial_run ; +    mfun_trial_run := false ; +fi ; + +if unknown mfun_first_run : +    boolean mfun_first_run ; +    mfun_first_run := true ; +fi ; + +def mfun_reset_tex_texts = +    mfun_tt_n := 0 ; +    mfun_tt_p := nullpicture ; +    mfun_tt_o := nullpicture ; % redundant +    mfun_tt_c := nullpicture ; % redundant +enddef ; + +def mfun_flush_tex_texts = +    addto currentpicture also mfun_tt_p +enddef ; + +extra_beginfig := extra_beginfig & "mfun_reset_tex_texts ;" ; +extra_endfig   := "mfun_flush_tex_texts ; mfun_reset_tex_texts ; " & extra_endfig ; + +vardef colordecimals primary c = +    if cmykcolor c  : +        decimal cyanpart c & ":" & decimal magentapart c & ":" & decimal yellowpart c & ":" & decimal blackpart c +    elseif rgbcolor c : +        decimal redpart c & ":" & decimal greenpart c & ":" & decimal bluepart c +    else : +        decimal c +    fi +enddef ; + +vardef rawtextext(expr str) = % todo: avoid currentpicture +    if str = "" : +        nullpicture +    else : +        mfun_tt_n := mfun_tt_n + 1 ; +        mfun_tt_c := nullpicture ; +        if mfun_trial_run : +            mfun_tt_o := nullpicture ; +            addto mfun_tt_o doublepath origin _op_ ; % save drawoptions +            addto mfun_tt_c doublepath unitsquare +                withprescript "tx_number=" & decimal mfun_tt_n +                withprescript "tx_stage=trial" +                withprescript "tx_color=" & colordecimals colorpart mfun_tt_o +                withpostscript str ; +            addto mfun_tt_p also mfun_tt_c ; +        elseif known mfun_tt_d[mfun_tt_n] : +            addto mfun_tt_c doublepath unitsquare +                xscaled mfun_tt_w[mfun_tt_n] +                yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n]) +                shifted (0,-mfun_tt_d[mfun_tt_n]) +                withprescript "tx_number=" & decimal mfun_tt_n +                withprescript "tx_stage=final" ; +        else : +            addto mfun_tt_c doublepath unitsquare ; % unitpicture +        fi ; +        mfun_tt_c +    fi +enddef ; + +primarydef str infont name = % nasty hack +    if name = "" : +        rawtextext(str) +    else : +        rawtextext("\definedfont[" & name & "]" & str) +    fi +enddef ; + diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index 11bf9b8d0..5e7a15395 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -142,73 +142,7 @@ extra_beginfig := extra_beginfig & "mfun_reset_tex_texts ;" ;  % flush twice: once in location in order to pick up e.g. color properties,  % and once at the end because we need to flush missing ones. -% vardef rawtextext(expr str) = -%     if str = "" : -%         nullpicture -%     elseif mfun_trial_run : -%         mfun_tt_n := mfun_tt_n + 1 ; -%         mfun_tt_o := image(draw origin) ; % save drawoptions -%         addto mfun_tt_p doublepath unitsquare -%             withprescript "tx_number=" & decimal mfun_tt_n -%             withprescript "tx_stage=extra" -%             withpostscript str ; -%         image ( -%             addto currentpicture doublepath unitsquare -%                 withprescript "tx_number=" & decimal mfun_tt_n -%                 withprescript "tx_stage=trial" -%                 withprescript "tx_color=" & colordecimals colorpart mfun_tt_o -%                 withpostscript str -%         ; ) -%     else : -%         mfun_tt_n := mfun_tt_n + 1 ; -%         if known mfun_tt_d[mfun_tt_n] : -%             image ( -%                 addto currentpicture doublepath unitsquare -%                     xscaled mfun_tt_w[mfun_tt_n] -%                     yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n]) -%                     withprescript "tx_number=" & decimal mfun_tt_n -%                     withprescript "tx_stage=final" -%                   % withpostscript str ; % for tracing -%             ; ) shifted (0,-mfun_tt_d[mfun_tt_n]) -%         else : -%             image ( -%                 addto currentpicture doublepath unitsquare -%             ; ) -%         fi -%     fi -% enddef ; - -% vardef rawtextext(expr str) = % todo: avoid currentpicture -%     if str = "" : -%         nullpicture -%     else : -%         mfun_tt_n := mfun_tt_n + 1 ; -%         mfun_tt_c := nullpicture ; -%         if mfun_trial_run : -%             mfun_tt_o := nullpicture ; -%             addto mfun_tt_o doublepath origin _op_ ; % save drawoptions -%             addto mfun_tt_p doublepath unitsquare -%                 withprescript "tx_number=" & decimal mfun_tt_n -%                 withprescript "tx_stage=extra" -%                 withpostscript str ; -%             addto mfun_tt_c doublepath unitsquare -%                 withprescript "tx_number=" & decimal mfun_tt_n -%                 withprescript "tx_stage=trial" -%                 withprescript "tx_color=" & colordecimals colorpart mfun_tt_o -%                 withpostscript str ; -%         elseif known mfun_tt_d[mfun_tt_n] : -%             addto mfun_tt_c doublepath unitsquare -%                 xscaled mfun_tt_w[mfun_tt_n] -%                 yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n]) -%                 shifted (0,-mfun_tt_d[mfun_tt_n]) -%                 withprescript "tx_number=" & decimal mfun_tt_n -%                 withprescript "tx_stage=final" ; -%         else : -%             addto mfun_tt_c doublepath unitsquare ; % unitpicture -%         fi ; -%         mfun_tt_c -%     fi -% enddef ; +% see mp-keep.mpiv for older code  vardef rawtextext(expr str) = % todo: avoid currentpicture      if str = "" : | 
