Index of /graphics/mf2tex
      Name                    Last modified       Size  Description

[DIR] Parent Directory 23-Mar-2017 17:48 - [DIR] example/ 20-Oct-1999 17:22 - [TXT] log2tex.c 14-Mar-1997 11:00 1k [   ] log2tex.exe 14-Mar-1997 11:00 4k [TXT] log2tex.pas 14-Mar-1997 11:00 1k [   ] 14-Mar-1997 11:00 2k [TXT] mf2tex.tex 14-Mar-1997 11:00 2k [TXT] mf2tex.txt 14-Mar-1997 11:00 8k

			  --- MF2TEX ---
	  Inserting the TeX labels into METAFONT sources

	  Robert Spalek,

   These macros are copyleft and may be freely distributed under the
		  General Public License (GPL)

	If  you  use  the  METAFONT  not  only	for  drawing fonts, but for
pictures too, you ofted need to insert labels into it (graphs, contructions
etc.)  METAFONT  can  draw dots, curves..., but not the text. Of course you
can  write  macros  in	TeX, which insert the given text in right place and
than insert the picture as a char. This solution has 2 problems:
- you must write  2  sources  (METAFONT  with  picture and TeX with labels)
- you must compute  the  right	coordinates, remember them, insert into the
  TeX source and  actualise them after EVERY change in METAFONT source

	It  would  be  nice,  if  we  could describe the labels in METAFONT
source	and METAFONT with TeX would together typeset picture with labels in
right places.

	METAFONT usually reads the source, draws the picture (and writes it
into TFM and GF files). If we make him to compute the coordinates and write
them  into  a  text  file,  another  program can read them and generate the
corresponding  TeX  source.  In our text we must only include generated TeX
source	and  insert  predefined  command  in  the  place, where we want the
picture to be.

	I implemented it in this way: METAFONT can't write into files, only
into  its  LOG	file. My macros write complete TeX source into the LOG file
in  a special format. A program LOG2TEX reads the LOG file and extracts the
source	into  the  TeX file. The TeX file uses special macros for inserting
the text in the right place, which are included too.

	Informations about using these macros are following:


1) at first you include my macros by `input mf2tex'

2) then you define the mode, measures...

   after the initialisation you write `labelheader("test");',
   where `test' is the name of the font, which do you want to use in
   the TeX source (the font will have the name `fonttest' and all
   characters will have the `test' prefix in their names).

3) instead `beginchar(char,width,height,depth);' you write
   where `one' is the name of the defined character (used in the TeX
   macros). In my example the generated TeX macro will have name `testone'
   (it couldl be inserted into text by writing `\testone').

4) instead `endchar;' you write `endlabeledchar;'

5) at the end the METAFONT source you write `labelfoot;', which will
   finalise the output file

!) when you want to insert a label into a character, you write
   `labelXY(posx,posy,"text")', where X and Y mean justification. They
   must be one of the following letters:
   X:	      L (left), R (right), M (middle)
   Y:	      U (up), D (down), B (baseline), M (middle),

   posx and posy are the coordinates (it need not be the number, it can
   be the variable or dot too (x1, 1/2[x3,x7]...))

   and text is the inserted text. You should switch into the right font
   at the beginning, because you don't know, which font will be active
   in the moment of the picture insertion. You MUST NOT insert characters
   with ASCII code >127, because METAFONT will ignore them. If you need at
   example the letters with interpuction, you should use the TeX accents.
 Note: of course you could use all the TeX features (math mode, tables...)


     Simply run the program `log2tex test1', where test1 is the name of the
METAFONT LOG file without extension.


1) at the beginning of the document write `\input mf2tex' (once and only
   once for the whole document)

2) then include all the generated sources (one for every METAFONT source):
   `\input test1'

3) when you want to insert the picture, write `\testone', where `test' is
   the name of the font and `one' is the name of the character in the font.
   This should work in all modes (horisontal, vertical, math...).
   Allocated space will be computed from the size of the picture (not
   including the labels!)

How do the TeX macros work

	I  wrote the macros \vertY, where Y is in {U,D,B,M}, which move the
pointer  into  the  given coordinate and insert the text with that vertical
justification.	You  MUST  NOT	insert	the text directly, but use the next
macro  \horX,  where  X  is in {L,R,M}, which will set the right horisontal

	You  don't  need  to  use  these  ugly macros, because I predefined
abbreviations  \moveXY(xpos,ypos,text}).  They	call these macros. You must
pay  attention in the text parameter, because it must not contain the right
paranthese  `)'.  If you need it, you must enclose the text parameter by {}
parantheses and it will be all right.

	For  inserting	the  picture  in  the  right  (horisontal)  mode is
predefined  the \labels macro with 2 parameters: the list of the labels and
the inserted char. User will call this macro.

	But you don't need to know these macros, METAFONT will generate the
source and you only use it.

	The program LOG2TEX reads the name of the generated TeX source file
from  the  line,  which  start by $#@!. Than it copies all the lines, which
begin bye !@#$ to that file. It does not do anything else, the complete TeX
source is generated by the METAFONT macros.

	I  include  the  2  sources  of  the  LOG2TEX program: Pascal and C
sources. I include a DOS executable program too.

Example of the METAFONT, LOG file, generated TeX file and TeX source:

    input mf2tex



	    z3-z1=(z2-z1) rotated 60;
	    pickup pencircle scaled mypen;
	    draw z1--z2--z3--cycle;		    %big triangle

	    z4=1/3[z1,z2]; z5=2/3[z1,z2];
	    z6=1/3[z2,z3]; z7=2/3[z2,z3];
	    z8=1/3[z3,z1]; z9=2/3[z3,z1];
	    draw z4--z7--z8--z5--z6--z9--cycle;     %3 middle triangles

	    labelMM(x9,1/3[y4,y9],"A"); 	    %6 letters

	    labelMM(x4,2/3[y4,y9],"a"); 	    %next 3 letters




    This is METAFONT, Version 2.71(c)sb13 (preloaded base=plain 96.5.2)
    13 MAR 1997 18:17
    ** &plain \mode=hplaser; mag=1.0; input test1
    ( (
    !@#$}{\fonttest \char1}}
    Font metrics written on test1.tfm.
    Output written on test1.300 (1 character, 3072 bytes).



    }{\fonttest \char1}}


    \input mf2tex
    \input test1

    This is a text before the picture, because we want it to be inserted in
    the middle of the text. Now we are able to insert it: ``One, two,
    \testone, four.'' Is it displayed all right? Let's display it