> as far as I know, metapost from tetex does not work
> with groff and has difficulties with font changes
> in non-tex labels.

A sample. Not well tested. (I'm not familiar with groff.)


                           README.groff

(1) patch -p0 <mpware-groff.patch in the directory texk/web2c.
(2) define GROFF in the Makefile like XDEFS = -DGROFF=1
(3) edit texmf.cnf and check TRFONTS, e.g.,
    TRFONTS = /usr/local/lib/groff/font/devps
(4) edit the script makempx to use geqn and gtroff.
(5) make a file texmf/metapost/support/grchars.adj with zero size.
(6) erase a line "tcommand" in .../groff/font/devps/DESC.

Sample usage:
mpost --troff fig
.PSPIC fig.1 5c 3c          (in groff source foo.1)
groff -mpspic foo.1 >foo.ps




diff -Nur mpware-orig/dmp.c mpware/dmp.c
--- mpware-orig/dmp.c   Tue Nov 20 05:17:08 2001
+++ mpware/dmp.c        Sun Nov 17 00:06:32 2002
@@ -59,7 +59,11 @@
 #define FCOUNT 100     /* maximum number of fonts */
 #define SHIFTS 100     /* maximum number of characters with special shifts */
 #define line_length 79 /* maximum output line length (must be at least 60) */
+#ifdef GROFF
+#define Hprime 512     /* much bigger than max(chars/font,fonts/job) */
+#else
 #define Hprime 307     /* much bigger than max(chars/font,fonts/job) */
+#endif
 #define MAXCHARS 256   /* character codes fall in the range 0..MAXCHARS-1 */
 #define LLENGTH 1024   /* one more than maximum line length for troff output */
 
@@ -92,8 +96,12 @@
 int curfont;                   /* internal number for current font */
 float Xslant;                  /* degrees additional slant for all fonts */
 float Xheight;                 /* yscale fonts to this height if nonzero */
-char *dbname = "trfonts.map";  /* file for table of troff & TFM font names */
+#ifdef GROFF
+char *adjname = "grchars.adj"; /* file for character shift amounts */
+#else
 char *adjname = "trchars.adj"; /* file for character shift amounts */
+#endif
+char *dbname = "trfonts.map";  /* file for table of troff & TFM font names */
 #define tfmpath kpse_tfm_format
 #define dbpath kpse_mpsupport_format
 #define trpath kpse_troff_font_format
@@ -234,6 +242,60 @@
 }
 
 
+#ifdef GROFF
+int get_dho(char *s)
+{
+    int i, d, neg, dho, kk;
+/*
+dho = 0 : 08
+dho = 1 : 10
+dho = 2 : 16
+*/
+    if (s==NULL) goto bad;
+    for (neg=0;; s++)
+       if (*s=='-') neg=!neg;
+       else if (*s!=' ' && *s!='\t') break;
+    if (i= *s-'0', 0>i || i>9) goto bad;
+    if((*s == '0') && (toupper(*(s+1)) != 'X')) {
+      dho = 0;
+      s++;
+    }
+    else if((*s == '0') && (toupper(*(s+1)) == 'X')) {
+      dho = 2;
+      s += 2;
+    }
+    else dho = 1;
+    i = 0;
+    if(dho == 0) {
+      while (d= *s-'0', 0<=d && d<=7) {
+       i = 8*i + d;
+       s++;
+      }
+      arg_tail = s;
+    }
+    else if(dho == 1) {
+      while(d = *s - '0', 0 <= d && d <=9) {
+       i = 10 * i + d;
+       s++;
+      }
+      arg_tail = s;
+    }
+    else if(dho == 2) {
+      while(kk = toupper(*s), ('0' <= kk && kk <= '9') ||
+                              ('A' <= kk && kk <= 'F')) {
+       if(kk <= '9') d = kk - '0';
+       else d = kk - 'A' + 10;
+       i = 16 * i + d;
+       s++;
+      }
+      arg_tail = s;
+    }
+    else goto bad;
+    return neg ? -i : i;
+bad:arg_tail = NULL;
+    return 0;
+}
+#endif
 /* Troff output files contain few if any non-integers, but this program is
    prepared to read floats whenever they seem reasonable; i.e., when the
    number is not being used for character positioning.  (For non-PostScript
@@ -436,9 +498,20 @@
     if (*lin=='"')
        *hfind(s,charcodes[f]) = lastcode;
     else {
+#ifdef GROFF
+        while((*lin >='0' && *lin <='9') || (*lin == ',')
+              || (*lin == '-') || (*lin == '+'))
+         lin++;
+       arg_tail = lin;
+#else
        (void) get_float(lin);
+#endif
        (void) get_int(arg_tail);
+#ifdef GROFF
+       lastcode = get_dho(arg_tail);
+#else
        lastcode = get_int(arg_tail);
+#endif
        if (arg_tail==NULL) return 0;
        *hfind(s,charcodes[f]) = lastcode;
        if (lastcode<0 || lastcode>=MAXCHARS) return 0;
@@ -647,7 +720,11 @@
        else end_char_string(47);
        fprintf(mpxf,")infont n%d", font_num[str_f]);
        slant_and_ht();
+#ifdef GROFF
+       fprintf(mpxf,",%.5f,%.4f,%.4f);\n", m / 1000, x,y);
+#else
        fprintf(mpxf,",%.5f,%.4f,%.4f);\n", m, x,y);
+#endif
        str_f = -1;
     }
 }
diff -Nur mpware-orig/mpto.c mpware/mpto.c
--- mpware-orig/mpto.c  Sat Nov 17 03:47:46 2001
+++ mpware/mpto.c       Sun Nov 17 00:05:29 2002
@@ -39,6 +39,7 @@
 
 #ifdef WIN32
 #include <string.h>
+#include <kpathsea/kpathsea.h>
 #endif
 
 
@@ -59,11 +60,21 @@
 
 char*  troff_predoc = ".po 0\n";
 char*  troff_postdoc = "";
+#ifdef GROFF
+char*  troff_pretex1 = ".lf %d %s\n";  /* first instance */
+char*  troff_pretex = ".bp\n.lf %d %s\n";      /* subsequent instances */
+#else
 char*  troff_pretex1 = ".lf line %d %s\n";     /* first instance */
 char*  troff_pretex = ".bp\n.lf line %d %s\n"; /* subsequent instances */
+#endif
 char*  troff_posttex = "\n";
+#ifdef GROFF
+char*  troff_preverb1 = ".lf %d %s\n";
+char*  troff_preverb = ".lf %d %s\n";
+#else
 char*  troff_preverb1 = ".lf line %d %s\n";
 char*  troff_preverb = ".lf line %d %s\n";
+#endif
 char*  troff_postverb = "\n";
 
 char*  predoc;
@@ -344,7 +355,7 @@
            bufsize = INF_BUF_SIZE;
         if (bufsize > SUP_BUF_SIZE)
            bufsize = SUP_BUF_SIZE;
-        buf = (char*)xmalloc(bufsize);
+        buf = (char *)xmalloc(bufsize);
         if (buf_size_str) free(buf_size_str);
 
        /* This is far from elegant, but life is short.  */
@@ -371,6 +382,6 @@
        while (getline()!=NULL)
                do_line();
        printf("%s",postdoc);
-        free(buf);
+       free(buf);
        exit(0);
 }

Reply via email to