Index: kit/CHANGELOG
diff -u kit/CHANGELOG:1.9 kit/CHANGELOG:removed
--- kit/CHANGELOG:1.9	Sat Sep  5 00:11:21 1998
+++ kit/CHANGELOG	Mon Sep 15 05:10:01 2003
@@ -1,51 +0,0 @@
-CHANGELOG for magicpoint
-$Id: CHANGELOG,v 1.9 1998/09/04 15:11:21 onoe Exp $
-
-Fri Sep  5 1998  onoe@sm.sony.co.jp
-	* handle key inputs from invoked terminal as pressed on Xserver,
-	  even if the Xserver is running on a remote host.
-
-Mon Aug 26 1998  itojun@iijlab.net
-	* new copyright. (BSDish copyright without clause 3)
-
-Mon Aug 25 1998  itojun@iijlab.net
-	* print.c: better x11/freetype/vflib -> postscript font mapping.
-
-Mon Aug 23 1998  kato@wide.ad.jp
-	* embedded image support (added mgpembed.pl and embed.c)
-
-Mon Aug 22 1998  itojun@iijlab.net
-	* added contrib/xmindpath, MindPath PocketPoint user-level driver.
-
-Fri Jul 10 11:57:59 JST 1998  itojun@iijlab.net
-	* cache gs-generated image file.
-	  Suggested by: luigi@FreeBSD.org
-
-Mon Jul  6 11:38:32 JST 1998  itojun@iijlab.net
-	* capable of handling GB2312 and KSC5601 encoding.
-	  they must be encoded by using iso-2022 like escape sequences.
-	  EUC-cn or EUC-kr does not work.
-	* -x option is added.
-
-Thu Jul  2 18:04:16 JST 1998  itojun@iijlab.net
-	* eliminate gsview.
-	* revamp "xfont" directive. (see SYNTAX for detail)
-
-Thu Jun 25 13:10:28 JST 1998  itojun@iijlab.net
-	* print.c: color postscript support by "mgp2ps -c".
-
-changes between 1.02a and 1.03a:
-	* To allow color name that has space inbetween ("dark blue"), 
-	  color name after directives SHOULD come with doublequote.
-	  Therefore,
-		%fore blue
-	  should be
-		%fore "blue"
-	  At this moment, doublequote can be ommitted for backward
-	  compatibility.  We may require to have doublequote in the future.
-	  Font names and other string parameter obeys the same rule.
-	* %image is now capable of rendering encapsulated postscript files
-	  (*.eps).
-		%image foo.eps
-	  should work fine.
-	  By using -X option, you can specify device name for ghostscript.
Index: kit/README
diff -u kit/README:1.43 kit/README:1.44
--- kit/README:1.43	Thu Apr 12 12:27:53 2001
+++ kit/README	Fri Sep 12 11:04:54 2003
@@ -2,7 +2,7 @@
 
 	     MagicPoint - an X11 based presentation tool
 
-			    April 12, 2001
+			    September 9, 2003
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -101,6 +101,20 @@
 	% su
 	# make install
 	# make install.man
+
+Alternatively you can build a native package (RPM, DEB, PKG, ...) for
+your operating system with the EPM package manager (freely available
+from http://www.easysw.com/epm/) and install this package. The configu-
+ration file for the packages is "mgp.list".
+
+The EPM method has the advantage that you can uninstall magicpoint later
+if you no longer need it or want to upgarde to a new version. The following
+commands for instance generate a Debian package and a RPM package on linux
+systems:
+
+	% su                    # necessary on Debian only
+	$ epm -f deb -nm mgp    # creates DEB in subdirectory linux-*/
+	$ epm -f rpm -nm mgp    # creates RPM in subdirectory linux-*/
 
 If you want to paste EPS figures into your presentation, you will need
 to install "ghostscript" or "alike".
Index: kit/SYNTAX
diff -u kit/SYNTAX:1.36 kit/SYNTAX:1.37
--- kit/SYNTAX:1.36	Sat Apr 12 07:05:41 2003
+++ kit/SYNTAX	Fri Sep 12 11:04:54 2003
@@ -1,4 +1,4 @@
-$Id: SYNTAX,v 1.36 2003/04/11 22:05:41 nishida Exp $
+$Id: SYNTAX,v 1.37 2003/09/12 02:04:54 nishida Exp $
 
 placement restriction for directives:
 		.mgprc		preamble	main pages
@@ -13,9 +13,27 @@
 others		x		x		okay
 
 
+%%
+	Comment lines.
+
 #
 	Comment lines.
 
+\# (at the beginning of a line)
+	Shows the character #.
+
+\% (at the beginning of a line)
+	Shows the character %.
+
+\
+	Followed by an escape sequence. Currently supported:
+
+	- \\ converts to the character \.
+	- \xHH (case insensitiv), where HH are hexadecimal digits.
+	  Converts to the ASCII-character number HH.
+
+	Escaping is switched off in Unicode.
+
 \ (at the end of line)
 	Line continuation.  Spaces/tabs at the beginning of next line
 	will be ignored.
@@ -172,7 +190,7 @@
 	Same as %image, but it is much easier to understand.
 	options include:
 	    -colors numcolors
-	    -xysize piel pixel
+	    -xysize pixel pixel
 	    -zoom percentage
 	    -xyzoom x-percentage y-percentage
 		Percentage is against the original image.
@@ -366,3 +384,20 @@
 	<value> :: transparency of the font. (0-100) 
 	Value 0 means that the font will be drawn with full tranparency.
 	NOTE: To use this directive, you need to build mgp with Xft2.
+
+%setsub <sup offset> <sub offset> <scale>
+	Initialize values for subsequent %sup (superscript) and 
+	%sub (subscript) commands.
+	<sup offset> :: set superscript offset (percentage of font size)
+	<sub offset> :: set superscript offset (percentage of font size)
+	<scale> :: scale factor for super-/subscript font size
+	The range of all three integer values goes from 10 to 100.
+	When unset, the default value %setsub 40 15 60 is used.
+
+%sup
+	Writes the immediately following line as superscript.
+	Only works in connection with %cont.
+
+%sub
+	Writes the immediately following line as subscript.
+	Only works in connection with %cont.
Index: kit/ctlwords.pl
diff -u kit/ctlwords.pl:1.2 kit/ctlwords.pl:removed
--- kit/ctlwords.pl:1.2	Sat Sep  5 06:05:08 1998
+++ kit/ctlwords.pl	Mon Sep 15 05:10:01 2003
@@ -1,12 +0,0 @@
-#! /usr/bin/perl
-$counter = 0;	# 0 origin
-print "/* generated by ctlwords.awk. do not edit by hand. */\n";
-
-while (<>) {
-	next if (!/^\/\*CTL\*\//);
-	next if ($_ !~ /(CTL_[A-Z0-9]+)/);
-
-	$word = $1;
-	print "#define $word\t$counter\n";
-	$counter++;
-}
Index: kit/draw.c
diff -u kit/draw.c:1.206 kit/draw.c:1.207
--- kit/draw.c:1.206	Wed May 14 16:45:35 2003
+++ kit/draw.c	Fri Sep 12 11:04:54 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: draw.c,v 1.206 2003/05/14 07:45:35 nishida Exp $
+ * $Id: draw.c,v 1.207 2003/09/12 02:04:54 nishida Exp $
  */
 
 #include "mgp.h"
@@ -275,6 +275,8 @@
 {
 	state->ypos = 0;
 	state->have_mark = 0;
+	state->charoff = 0;
+	char_size[caching] = nonscaled_size[caching];   
 	free_alloc_colors(&image_clr);
 	free_alloc_colors(&font_clr);
 
@@ -489,8 +491,46 @@
 	}
 
 	switch(cp->ct_op) {
+	case CTL_SUP:
+	        if (sup_scale > 1.0 || sup_scale < 0.1){
+		      sup_scale = DEFAULT_SUPSCALE;
+		}
+	        if (sup_off > 1.0 || sup_scale < 0.1){
+		      sup_off = DEFAULT_SUPOFF;
+		}
+	        state->charoff = -sup_off * nonscaled_size[caching];	   
+		char_size[caching] = (int)(nonscaled_size[caching] * sup_scale);
+	        break;
+	case CTL_SUB:
+	        if (sup_scale > 1.0 || sup_scale < 0.1){
+		      sup_scale = DEFAULT_SUPSCALE;
+		}
+	        if (sub_off > 1.0 || sub_off < 0.1){
+		      sub_off = DEFAULT_SUBOFF;
+		}
+	        state->charoff = sub_off * nonscaled_size[caching];
+		char_size[caching] = (int)(nonscaled_size[caching] * sup_scale);
+	        break;
+	case CTL_SETSUP:
+	        if (cp->cti3_value1 > 100 || cp->cti3_value1 < 10){
+	             sup_off = DEFAULT_SUPOFF;
+		}else{
+		     sup_off = cp->cti3_value1 / 100.;
+		}
+	        if (cp->cti3_value2 > 100 || cp->cti3_value2 < 10){
+	             sub_off = DEFAULT_SUBOFF;
+		}else{
+		     sub_off = cp->cti3_value2 / 100.;
+		}
+	        if (cp->cti3_value3 > 100 || cp->cti3_value3 < 10){
+		     sup_scale = DEFAULT_SUPSCALE;
+		}else{
+		     sup_scale = cp->cti3_value3 / 100.;
+		}
+	        break;
 	case CTL_SIZE:
-		char_size[caching] = state->height * cp->ctf_value / 100;
+	        nonscaled_size[caching] = state->height * cp->ctf_value / 100;
+		char_size[caching] = nonscaled_size[caching];
 #ifdef FREETYPE
 		tfc_setsize(char_size[caching]);
 #endif
@@ -562,6 +602,8 @@
 		break;
 
 	case CTL_CONT:
+      	        state->charoff = 0;
+ 	        char_size[caching] = nonscaled_size[caching];
 		break;
 
 #ifdef VFLIB
@@ -675,6 +717,8 @@
 		break;
 
 	case CTL_LINESTART:
+      	        state->charoff = 0;
+ 	        char_size[caching] = nonscaled_size[caching];
 		if (state->line == 0) {
 			/*
 			 * set background of target 
@@ -717,6 +761,7 @@
 	case CTL_LINEEND:
 		/* blank lines */
 		if (state->brankline) {	/*XXX*/
+			state->max_lineascent = char_size[caching];
 			state->maxascent = char_size[caching];
 			state->maxdescent = VERT_GAP(char_size[caching]);
 		}
@@ -890,6 +935,8 @@
 {
 	struct render_object *obj;
 
+	state->max_lineascent = 0;
+	state->max_linedescent = 0;
 	state->maxascent = 0;
 	state->maxdescent = 0;
 	state->linewidth = 0;
@@ -904,10 +951,23 @@
 	int ascent;
 	int descent;
 {
+	ascent -= state->charoff;
+	descent += state->charoff;
 	if (ascent > state->maxascent)
 		state->maxascent = ascent;
 	if (descent > state->maxdescent)
 		state->maxdescent = descent;
+
+	/*
+	 * calculation for the height of a line should ignore
+	 * character offset
+	 */
+	if (state->charoff == 0) {
+		if (ascent > state->max_lineascent)
+			state->max_lineascent = ascent;
+		if (descent > state->max_linedescent)
+			state->max_linedescent = descent;
+	}
 }
 
 
@@ -949,16 +1009,17 @@
 			obj_free(state, state->obj);
 	}
 
-	state->ypos += state->maxascent;
+	state->ypos += state->max_lineascent;
 
 	/* 
-  	 * we should ignore height of images to calculate line gap.
+ 	 * we should ignore height of images to calculate line gap.
 	 * suggested by Toru Terao 
 	 */ 
-	if (VERT_GAP(char_size[caching]) < state->maxdescent)
-		state->ypos += state->maxdescent;
+	if (VERT_GAP(char_size[caching]) < state->max_linedescent)
+		state->ypos += state->max_linedescent;
 	else
 		state->ypos += VERT_GAP(char_size[caching]);
+
 	state->ypos += 2;
 }
 
@@ -1308,7 +1369,7 @@
 #ifdef VFLIB
 		case MODE_VFLIB:
 			char_len = draw_onechar_vf(state, code,
-				state->linewidth, 0,
+				state->linewidth, state->charoff,
 				registry ? char_size[caching]
 					 : (char_size[caching] * 4 / 5), /*XXX*/
 				char_size[caching]);
@@ -1322,7 +1383,7 @@
 			 * metric info derived from TrueType font file.
 			 */
 			char_len = draw_onechar_tf(state, code,
-				state->linewidth, 0,
+				state->linewidth, state->charoff,
 				char_size[caching], registry,
 				(len == (charset16 ? 2 : 1)) ? 1 : 0,
 				charset16);
@@ -1335,7 +1396,7 @@
 		case MODE_UNKNOWN:
 		case MODE_X:
 			char_len = draw_onechar_x(state, code,
-				state->linewidth, 0, char_size[caching],
+				state->linewidth, state->charoff, char_size[caching],
 				registry, (len == (charset16 ? 2 : 1)) ? 1 : 0);
 			if (char_len == 0) {
 				fprintf(stderr, "can't load font size %d "
@@ -1400,7 +1461,6 @@
 			state->obj = thisline;
 		state->objlast = thislineend;
 		state->align = backup.align;
-
 		/* fix up x position and maxascent. */
 		for (tail = state->obj; tail; tail = tail->next) {
 			tail->x -= startwidth;
@@ -1518,8 +1578,8 @@
 	obj->type = O_VFONT;
 	obj->data.vfc = vfc;
 	obj->data.vfc->size = size;
-	obj->ascent = obj->data.vfc->ascent;
-	obj->descent = obj->data.vfc->descent;
+	obj->ascent = obj->data.vfc->ascent - y;
+	obj->descent = obj->data.vfc->descent + y;
 	obj->vertloc = VL_BASE;
 	vfc->ref++;
 	return 1;
@@ -1543,8 +1603,8 @@
 	obj->fore = fore_color[caching];
 	obj->type = O_TFONT;
 	obj->data.tfc = tfc;
-	obj->ascent = obj->data.tfc->ascent;
-	obj->descent = obj->data.tfc->descent;
+	obj->ascent = obj->data.tfc->ascent - y;
+	obj->descent = obj->data.tfc->descent + y;
 	obj->vertloc = VL_BASE;
 	tfc->ref++;
 	return 1;
@@ -1572,8 +1632,8 @@
 	obj->data.xfont.csize = size;
 	obj->data.xfont.code = code;
 	obj->data.xfont.registry = registry;
-	obj->ascent = size;	/*XXX*/
-	obj->descent = 0;	/*XXX*/
+	obj->ascent = size - y;	/*XXX*/
+	obj->descent = -y;	/*XXX*/
 	obj->vertloc = VL_BASE;
 	return 1;
 }
@@ -1903,6 +1963,7 @@
 #endif
 	u_int isize;
 	int i;
+	int lineoff;   /* ypos correction for lines with superscripts */
 #ifdef RASTERLIB
 	XImage *bim, *xim;
 	u_long bcolor;
@@ -1924,6 +1985,12 @@
 	ypos += state->yoff;
 	fore = fore_color[caching];
 
+	/* 
+	 * only used with superscript offset for calculating the
+	 * exact line position (ypos correction)
+	 */
+	lineoff = state->maxascent - state->max_lineascent;
+
 #ifdef RASTERLIB
 	bcolor = back_color[caching];
 	for (obj = state->obj; obj; obj = obj->next) {
@@ -2035,6 +2102,7 @@
 				y -= obj->descent;
 				break;
 			}
+		        y += obj->y;
 #ifdef VFLIB
 			if (obj->type == O_VFONT) {
 				(void)vfc_image(obj->data.vfc,
@@ -2057,7 +2125,8 @@
 		for (i = 0; i < areaindex; i ++)
 			XPutImage(display, target, gcfore, xim,
 				drawarea[i].x, drawarea[i].y,
-				drawarea[i].x + xpos, ypos + drawarea[i].y,
+				drawarea[i].x + xpos,
+				ypos + drawarea[i].y - lineoff,
 				drawarea[i].width, drawarea[i].height);
 #endif
 		XDestroyImage(xim);
@@ -2116,18 +2185,28 @@
 			break;
 #ifdef USE_XFT2
 		case O_XTFONT:
+			y += obj->y;
 			set_xrender_color(obj->fore, state->opaque);
 			xft_font = xft_setfont(obj->data.xftfont.fontname, 
-							obj->data.xftfont.size, obj->data.xftfont.registry);
+						obj->data.xftfont.size,
+						obj->data.xftfont.registry);
+
 			if (obj->data.xftfont.charset16){
-				XftDrawStringUtf8(xft_getdraw(target), &xft_forecolor, xft_font, 
-						x, y, obj->data.xftfont.data, obj->data.xftfont.len);
+				XftDrawStringUtf8(xft_getdraw(target),
+						&xft_forecolor, xft_font, 
+						x, y - lineoff,
+						obj->data.xftfont.data,
+						obj->data.xftfont.len);
 			} else
-				XftDrawString8(xft_getdraw(target), &xft_forecolor, xft_font, 
-						x, y, obj->data.xftfont.data, obj->data.xftfont.len);
+				XftDrawString8(xft_getdraw(target),
+						&xft_forecolor, xft_font, 
+						x, y - lineoff,
+						obj->data.xftfont.data,
+						obj->data.xftfont.len);
 			break;
 #endif
 		case O_XFONT:
+			y += obj->y;
 			code = obj->data.xfont.code;
 			registry = obj->data.xfont.registry;
 			(void)x_setfont(obj->data.xfont.xfont,
@@ -2142,17 +2221,18 @@
 			/* is it always okay? */
 			kch[0].byte1 = (code >> 8) & 0xff;
 			kch[0].byte2 = code & 0xff;
-			XDrawString16(display, target, gcfore, x, y, kch, 1);
+			XDrawString16(display, target, gcfore,
+					x, y - lineoff, kch, 1);
 #else
 			if (registry) {
 				kch[0].byte1 = (code >> 8) & 0xff;
 				kch[0].byte2 = code & 0xff;
 				XDrawString16(display, target, gcfore,
-					x, y, kch, 1);
+					x, y - lineoff, kch, 1);
 			} else {
 				ch[0] = code & 0xff;
 				XDrawString(display, target, gcfore,
-					x, y, ch, 1);
+					x, y - lineoff, ch, 1);
 			}
 #endif
 			break;
Index: kit/globals.c
diff -u kit/globals.c:1.48 kit/globals.c:1.49
--- kit/globals.c:1.48	Wed Apr 16 07:41:43 2003
+++ kit/globals.c	Fri Sep 12 11:04:54 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: globals.c,v 1.48 2003/04/15 22:41:43 nishida Exp $
+ * $Id: globals.c,v 1.49 2003/09/12 02:04:54 nishida Exp $
  */
 
 #include "mgp.h"
@@ -49,6 +49,7 @@
 u_int maxpage;
 u_int cur_page = 0;
 char *mgp_fname;
+char *mgp_wname;    /* window title */
 
 u_int parse_error = 0;
 u_int parse_debug = 0;
@@ -74,6 +75,10 @@
 u_long *free_clr = NULL;
 
 u_int char_size[2];
+u_int nonscaled_size[2];
+float sup_scale;
+float sup_off;
+float sub_off;
 u_int horiz_gap[2] = {DEFAULT_HGAP, DEFAULT_HGAP};
 u_int vert_gap[2] = {DEFAULT_VGAP, DEFAULT_VGAP};
 u_int depth;
@@ -151,5 +156,8 @@
 /*CTL*/	{ CTL_VALIGN,		T_SP,	"valign", 6 },
 /*CTL*/	{ CTL_AREA,		T_SP,	"area", 4 },
 /*CTL*/	{ CTL_OPAQUE,		T_INT,	"opaque", 6 },
+/*CTL*/	{ CTL_SUP,		T_VOID,	"sup", 3 },
+/*CTL*/	{ CTL_SUB,		T_VOID,	"sub", 3 },
+/*CTL*/	{ CTL_SETSUP,		T_INT,	"setsup", 6 },
 	{ 0, 0, NULL, 0 },
 };
Index: kit/grammar.y
diff -u kit/grammar.y:1.42 kit/grammar.y:1.43
--- kit/grammar.y:1.42	Sat Apr 12 07:05:42 2003
+++ kit/grammar.y	Fri Sep 12 11:04:54 2003
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: grammar.y,v 1.42 2003/04/11 22:05:42 nishida Exp $
+ * $Id: grammar.y,v 1.43 2003/09/12 02:04:54 nishida Exp $
  */
 /*
  * partly derived from lbl libpcap source code, which has the following
@@ -179,6 +179,42 @@
 }
 
 static struct ctrl *
+gen_int2(op, v1, v2)
+       int op;
+       int v1;
+       int v2;
+{
+       struct ctrl *ct;
+
+       if (!(ct = ctlalloc1(op))) {
+               yyerror("cannot allocate integer2 node");
+               return ct;
+       }
+       ct->cti2_value1 = v1;
+       ct->cti2_value2 = v2;
+       return ct;
+}
+
+static struct ctrl *
+gen_int3(op, v1, v2, v3)
+       int op;
+       int v1;
+       int v2;
+       int v3;
+{
+       struct ctrl *ct;
+
+       if (!(ct = ctlalloc1(op))) {
+               yyerror("cannot allocate integer3 node");
+               return ct;
+       }
+       ct->cti3_value1 = v1;
+       ct->cti3_value2 = v2;
+       ct->cti3_value3 = v3;   
+       return ct;
+}
+
+static struct ctrl *
 gen_str(op, str)
 	int op;
 	char *str;
@@ -733,6 +769,7 @@
 %token KW_DEFFONT KW_FONT KW_TFONT0 KW_EMBED KW_ENDEMBED KW_NEWIMAGE
 %token KW_CHARSET KW_TMFONT KW_PCACHE KW_TMFONT0 KW_ANIM KW_VALIGN KW_AREA 
 %token KW_OPAQUE
+%token KW_SUP KW_SUB KW_SETSUP
 
 %type <ct> toplevel
 %type <ct> line defaultline tabline shellline deffontline
@@ -798,6 +835,9 @@
 	| KW_AGAIN	{ $$ = gen_void(CTL_AGAIN); }
 	| KW_MARK	{ $$ = gen_void(CTL_MARK); }
 	| KW_PAGE	{ $$ = gen_void(CTL_PAGE); }
+        | KW_SETSUP NUM NUM NUM { $$ = gen_int3(CTL_SETSUP, $2, $3, $4); }
+        | KW_SUP        { $$ = gen_void(CTL_SUP); }
+        | KW_SUB        { $$ = gen_void(CTL_SUB); }             
 	| KW_SIZE NUM	{ $$ = gen_double_int(CTL_SIZE, $2); }
 	| KW_SIZE DOUBLE	{ $$ = gen_double(CTL_SIZE, $2); }
 	| KW_HGAP NUM	{ $$ = gen_int(CTL_HGAP, $2); }
Index: kit/mgp.c
diff -u kit/mgp.c:1.129 kit/mgp.c:1.130
--- kit/mgp.c:1.129	Tue Jun 24 14:26:33 2003
+++ kit/mgp.c	Fri Sep 12 11:04:55 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: mgp.c,v 1.129 2003/06/24 05:26:33 kazu Exp $
+ * $Id: mgp.c,v 1.130 2003/09/12 02:04:55 nishida Exp $
  */
 
 static char *mgp_version = "1.10a (20030624)";
@@ -196,6 +196,9 @@
 	int argc;
 	char **argv;
 {
+	int i, j;              /* counters */
+	int tmp_argc;          /* number of current arguments */
+	char **tmp_argv;       /* manipulated 'argv' */
 	int opt;
 	extern char *optarg;
 	extern int optind;
@@ -221,6 +224,37 @@
 		mgpwdir = p;
 	}
 
+	/*
+	 * check for the argument '--title' to set the window's title:
+	 * go through the whole 'argv' and cut off this option since it
+	 * will not be accepted by getopt()
+	 * default title is 'MagicPoint'
+	 */
+	tmp_argv=(char**)malloc(argc*sizeof(char*));
+	tmp_argc=argc;
+	i=j=0;
+	while (i < argc)
+	{
+		if (strcmp(argv[i], "--title") == 0)
+		{
+			tmp_argc--;
+			if (++i < argc)
+			{
+				mgp_wname=strdup(argv[i]);
+				tmp_argc--;
+			}
+		}
+		else
+			tmp_argv[j++]=strdup(argv[i]);
+		i++;
+	}
+	/* set title to default if not set by user */
+	if (argc-1 <= tmp_argc)
+		mgp_wname=strdup("MagicPoint");
+
+	argv=tmp_argv;
+	argc=tmp_argc;
+
 #define ACCEPTOPTS	"Bd:vVob:c:eg:f:hlGp:qt:Q:PSUT:D:CORw:X:x:nF:E:"
 	while ((opt = getopt(argc, argv, ACCEPTOPTS)) != -1) {
 #undef ACCEPTOPTS
@@ -691,6 +725,7 @@
 	fprintf(stderr, "\t-P: print stderr from image conversion tools (by default it's discarded)\n");
 	fprintf(stderr, "\t-V: Be verbose\n");
 	fprintf(stderr, "\t-X <gsdevice>: ghostscript device to use\n");
+	fprintf(stderr, "\t--title <title>: Set window title\n");
 
 	exit(0);
 }
Index: kit/mgp.h
diff -u kit/mgp.h:1.134 kit/mgp.h:1.135
--- kit/mgp.h:1.134	Fri Jun  6 16:18:25 2003
+++ kit/mgp.h	Fri Sep 12 11:04:55 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: mgp.h,v 1.134 2003/06/06 07:18:25 nishida Exp $
+ * $Id: mgp.h,v 1.135 2003/09/12 02:04:55 nishida Exp $
  */
 
 #include <stdio.h>
@@ -109,6 +109,9 @@
 #define PAGELIST_KFONT	"k14"
 
 #define DEFAULT_CHARSIZE	10	/* 10% of height */
+#define DEFAULT_SUPSCALE	0.6
+#define DEFAULT_SUPOFF		0.4
+#define DEFAULT_SUBOFF		0.15
 #define DEFAULT_HGAP		0
 #define DEFAULT_VGAP		15
 #define DEFAULT_BQUALITY	100
@@ -198,6 +201,17 @@
 	u_int ct_value;
 };
 
+struct ctrl_int2 {
+       u_int ct_value1;
+        u_int ct_value2;
+};
+
+struct ctrl_int3 {
+       u_int ct_value1;
+        u_int ct_value2;
+        u_int ct_value3;
+	};
+
 struct ctrl_long {
 	u_long ct_value;
 };
@@ -289,6 +303,8 @@
 	union {
 		struct ctrl_double ctrl_double;
 		struct ctrl_int ctrl_int;
+                struct ctrl_int2 ctrl_int2;
+                struct ctrl_int3 ctrl_int3;        
 		struct ctrl_long ctrl_long;
 		struct ctrl_char ctrl_char;
 		struct ctrl_char2 ctrl_char2;
@@ -304,6 +320,11 @@
 
 #define ctf_value	ct_val.ctrl_double.ct_value
 #define cti_value	ct_val.ctrl_int.ct_value
+#define cti2_value1	ct_val.ctrl_int2.ct_value1
+#define cti2_value2	ct_val.ctrl_int2.ct_value2
+#define cti3_value1	ct_val.ctrl_int3.ct_value1
+#define cti3_value2	ct_val.ctrl_int3.ct_value2
+#define cti3_value3	ct_val.ctrl_int3.ct_value3
 #define ctl_value	ct_val.ctrl_long.ct_value
 #define ctc_value	ct_val.ctrl_char.ct_value
 #define ctc2_value1	ct_val.ctrl_char2.ct_value1
@@ -411,9 +432,12 @@
 	u_int repaint;
 	int maxascent;
 	int maxdescent;
+	int max_lineascent;   /* max size above baseline ignoring supscript */
+	int max_linedescent;  /* max size below baseline ignoring subscript */
 	u_int linewidth;
 	u_int brankline;
 	u_int opaque;
+	u_int charoff;
 	struct ctrl *xfont;
 	struct render_object *obj, *objlast;
 };
@@ -566,6 +590,7 @@
 extern u_int maxpage;
 extern u_int cur_page;
 extern char *mgp_fname;
+extern char *mgp_wname;
 
 extern u_int parse_error;
 extern u_int parse_debug;
@@ -585,6 +610,10 @@
 extern struct alloc_color font_clr;
 
 extern u_int char_size[2];
+extern u_int nonscaled_size[2];
+extern float sup_scale;
+extern float sup_off;
+extern float sub_off;
 extern u_int horiz_gap[2];
 extern u_int vert_gap[2];
 extern u_int depth;
Index: kit/mgp.man
diff -u kit/mgp.man:1.60 kit/mgp.man:1.61
--- kit/mgp.man:1.60	Wed May 21 18:07:26 2003
+++ kit/mgp.man	Fri Sep 12 11:04:55 2003
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\" 
-.\"	$Id: mgp.man,v 1.60 2003/05/21 09:07:26 nishida Exp $
+.\"	$Id: mgp.man,v 1.61 2003/09/12 02:04:55 nishida Exp $
 .\"
 .Dd November 1997
 .Dt MGP 1
@@ -151,6 +151,9 @@
 Current page is indicated by the position of a small vertical bar; the vertical
 bar is drawn at the leftend when the first page is displayed while the
 bar is drawn at the rightend when the last page is displayed.
+.It Fl Fl title Ar name
+Set the title of the window to
+.Ar name .
 .It Fl v
 Display the MagicPoint version and exit without performing a presentation.
 .It Fl w Ar wdir
Index: kit/parse.c
diff -u kit/parse.c:1.94 kit/parse.c:1.95
--- kit/parse.c:1.94	Wed Sep  3 04:01:28 2003
+++ kit/parse.c	Fri Sep 12 11:04:55 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: parse.c,v 1.94 2003/09/02 19:01:28 nishida Exp $
+ * $Id: parse.c,v 1.95 2003/09/12 02:04:55 nishida Exp $
  */
 
 #include "mgp.h"
@@ -42,6 +42,7 @@
 static void debug __P((void));
 static int define_font __P((struct ctrl *));
 static struct ctrl *find_font __P((char *));
+static char* clear_esc __P((char*));
 
 /*image*/
 extern int findImage __P((char *, char *));
@@ -133,6 +134,109 @@
 	}
 }
 
+/*
+ * clear the given data from escape sequences, so identifying
+ * a character by its hexadecimal value is possible by using \xHH
+ */
+static char*
+clear_esc(s)
+	char* s;
+{
+	char* p;
+	int len;
+	int i;
+	int j;
+	int k;
+	int error = 0;
+	int unicode = 0;
+	int chars;
+	unsigned int code;
+
+	i = j = 0;
+	len = strlen(s);
+	p = (char*)malloc(len + 1);
+
+	while (i < len)
+	{
+		code = 0x0;
+
+		/*
+		 * expecting either beginning of unicode or
+		 * an ascii-character (may be an escape sequence)
+		 */
+		if (!unicode) {
+			/* beginning of unicode */
+			if (s[i] == 0x1b && s[i+1] == '$' &&
+				'@' <= s[i+2] && s[i+2] < 'C') {
+				unicode = 1;
+
+				for (chars = 0; chars < 3; chars++)
+					p[j++] = s[i++];
+
+				continue;
+			}
+
+			/* backslash */
+			if (s[i] == 0x5c) {
+				i++;
+	
+				/* any escape sequence */
+				if (s[i] != 0x5c) {
+
+					 /* hexadecimal token: \xHH */
+					if ((s[i] == 'x' || s[i] == 'X') && i+2 < len) {
+						i++;
+	
+						if (isxdigit(s[i]) && isxdigit(s[i+1])) {
+							for (k = 2; k > 0; k--, i++) {
+								code <<= 4;
+	
+								if (isdigit(s[i]))
+									code += s[i] - 48;
+								else
+									code += tolower(s[i]) - 87;
+							}
+						} else
+							error = 1;
+					} else
+						error = 1;
+				}
+			}
+			if (error)
+				return (char*) NULL;
+
+			if (code == 0x0)
+				p[j++] = s[i++];
+			else
+				p[j++] = code;
+		} else {
+			/*
+			 * expecting either the end of unicode or
+			 * a part of a unicode character
+			 */
+
+			/* end of unicode */
+			if (s[i] == 0x1b && s[i+1] == '(' &&
+				(s[i+2] == 'B' || s[i+2] == 'J')) {
+				unicode = 0;
+
+				for (chars = 0; chars < 3; chars++)
+					p[j++] = s[i++];
+				
+				continue;
+			}
+
+			/* just take the unicode character */
+			p[j++] = s[i++];
+		}
+	}
+	p[j] = 0x0;
+	strcpy(s, p);
+	free(p);
+
+	return s;
+}
+	
 static struct ctrl *
 parse_text(p, page)
 	char *p;
@@ -437,7 +541,8 @@
 			continue;
 		}
 	    {
-		char *p, *q;
+		char *p, *q, *s;
+		int cnt;   /* counter for backslashes at the end of a line */
 
 		p = buf + strlen(buf);
 		if (buf < p && p[-1] == '\n') {
@@ -445,6 +550,22 @@
 			*p = '\0'; 
 		}
 		while (buf < p && p - buf < sizeof(buf) && p[-1] == '\\') {
+
+			/*
+			 * check for quoted backslashes at the end of a line:
+			 * if it is so, then do NOT ignore the line break and
+			 * continue as usual
+			 */
+			s = p;
+			cnt = 0;
+			while (buf < s && s[-1] == '\\') {
+				s--;
+				cnt++;
+			}
+
+			if (cnt % 2 == 0)
+				break;
+
 			p--;
 			if (fgets(buf2, sizeof(buf) - (p - buf), fp) == NULL)
 				break;
@@ -462,10 +583,7 @@
 	    }
 		if (buf[0] == '#')
 			continue;
-#if 1 /* escape # by backslash */
-		if (buf[0] == 0x5c && (buf[1] == 0x5c || buf[1] == 0x23))
-			memcpy(&buf[0], &buf[1], strlen(buf));
-#endif
+
 		if (buf[0] == '%') {
 			/* this is directive */
 			int pb;
@@ -482,7 +600,7 @@
 			lex_init(buf + 1);
 			if (yyparse() || n_errors) {
 				fprintf(stderr,
-					"%s:%d: fatal syntax error detected\n",
+					"%s:%d: fatal syntax error detected !!!\n",
 					filename, lineno);
 				exit(-1);
 			}
@@ -664,6 +782,27 @@
 			}
 		} else {
 			/* this is data */
+
+			/*
+			 * escape # and % by backslash (at the beginning
+			 * of a line)
+			 */
+			if (buf[0] == 0x5c && (buf[1] == 0x23 ||
+						buf[1] == 0x25))
+				memcpy(&buf[0], &buf[1], strlen(buf));
+
+			/*
+			 * clear escape sequences
+			 */
+#if 1
+			if (clear_esc(buf) == NULL) {
+				fprintf(stderr, "%s:%d: unknown escape"
+						" sequence\n",
+						filename, lineno);
+				exit(-1);
+			}
+#endif
+
 			cp = parse_text(buf, *page);
 			if (cp) {
 				ch = &page_control[*page][*line];
Index: kit/print.c
diff -u kit/print.c:1.103 kit/print.c:1.104
--- kit/print.c:1.103	Thu Aug  7 09:29:41 2003
+++ kit/print.c	Fri Sep 12 11:04:55 2003
@@ -26,19 +26,26 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: print.c,v 1.103 2003/08/07 00:29:41 kazu Exp $
+ * $Id: print.c,v 1.104 2003/09/12 02:04:55 nishida Exp $
  */
 /*
  * Paper size selection code is based on psutil.c by Angus J. C. Duggan
  */
 
 #include "mgp.h"
+#ifdef USE_SETLOCALE
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+#endif
 
 static u_int align = AL_LEFT;
 static char *curprefix = NULL;
 static char *tabprefix = NULL;
 static u_int lineheight;
 static u_int linewidth;
+static int char_off = 0;	/* y-offset of the chars (relative to the
+				   current line, used for super/subscript */
 
 #define DEFAULT_PAPER_SIZE	"a4"
 #define PRINT_ASCIIFONT		"Times-Roman"
@@ -73,6 +80,7 @@
 static struct textpool {
 	int pfx;
 	int xoffset;
+	int yoffset;     /* offset for super/subscript */
 	int xsiz;
 	struct fontmap *font;
 	int size;
@@ -126,6 +134,7 @@
 	{ CTL_TFONT, ASCII, "couri.ttf",	"Courier-Oblique" },
 	{ CTL_TFONT, ASCII, "courbd.ttf",	"Courier-Bold" },
 	{ CTL_TFONT, ASCII, "courbi.ttf",	"Courier-BoldOblique" },
+	{ CTL_TFONT, ASCII, "symbol.ttf",	"Symbol" },
 	{ CTL_TFONT, ASCII, "*",		"Helvetica" },	/*last resort*/
 #ifdef FREETYPE_CHARSET16
 	{ CTL_TMFONT, KANJI, "wadalab-gothic.ttf", "GothicBBB-Medium-H" },
@@ -324,6 +333,9 @@
 	window_height = w_height;
 
 	char_size[0] = window_height * DEFAULT_CHARSIZE / 100;
+	sup_off = DEFAULT_SUPOFF;
+	sub_off = DEFAULT_SUBOFF;
+	sup_scale = DEFAULT_SUPSCALE;
 
 	if (outputfile[0]) {
 		if ((fp = fopen(outputfile, "w")) == NULL) {
@@ -493,7 +505,7 @@
 	fprintf(fp, "/setymin {dup ymin lt {dup /ymin exch def} if pop} def\n");
 	fprintf(fp, "/calcy {dup ( ) eq\n"
 		"  {0 setymax 0 setymin pop}\n"
-		"  {false charpath flattenpath pathbbox setymax pop setymin pop}\n"
+		"  {pop charsize 0.7 mul setymax charsize -0.15 mul setymin}\n"
 		"  ifelse\n"
 		"} def\n");
 
@@ -786,6 +798,13 @@
 		print_line(cp->ctc_value, 0);
 		if (align == AL_LEFTFILL0)
 			align = AL_LEFTFILL1;
+
+		/* disable super/subscript for next line */
+		if (char_off != 0)
+		{
+			char_size[0]=nonscaled_size[0];
+			char_off=0;
+		}
 		break;
 	    }
 
@@ -849,6 +868,43 @@
 		fprintf(fp, "%f setgray\n", 1.0 - (float)cp->cti_value /100.0);
 		break;
 
+    /* setup for super/subscript */
+    case CTL_SETSUP:
+                if (cp->cti3_value1 > 100 || cp->cti3_value1 < 10){
+                     sup_off = DEFAULT_SUPOFF;
+                }else{
+                     sup_off = cp->cti3_value1 / 100.;
+                }
+                if (cp->cti3_value2 > 100 || cp->cti3_value2 < 10){
+                     sub_off = DEFAULT_SUBOFF;
+                }else{
+                     sub_off = cp->cti3_value2 / 100.;
+                }
+                if (cp->cti3_value3 > 100 || cp->cti3_value3 < 10){
+                     sup_scale = DEFAULT_SUPSCALE;
+                }else{
+                     sup_scale = cp->cti3_value3 / 100.;
+                }
+                break;
+
+    /* subscript */
+    case CTL_SUB:
+		/* save old size and set new one */
+		nonscaled_size[0] = char_size[0];
+		char_size[0] = char_size[0] * sup_scale;
+		char_off = nonscaled_size[0] * (-sub_off);
+		fprintf(fp, "%d setcharsize\n", char_size[0]);
+		break;
+
+    /* superscript */
+    case CTL_SUP:
+		/* save old size and set new one */
+		nonscaled_size[0] = char_size[0];
+		char_size[0] = char_size[0] * sup_scale;
+		char_off = nonscaled_size[0] * sup_off;
+		fprintf(fp, "%d setcharsize\n", char_size[0]);
+		break;
+
 	default:
 		break;
 	}
@@ -1023,7 +1079,17 @@
 		if (textpool[i].text) {
 			if (!textpool[i].pfx)
 				fprintf(fp, "updatefillzero ");
+
+			/* for super/subscript: modify the current y-position */
+			if (textpool[i].yoffset != 0)
+				fprintf(fp, "currentpoint %d add moveto ",
+					textpool[i].yoffset);
 			fprintf(fp, "show\n");
+
+			/* for super/subscript: reset the old y-position */
+			if (textpool[i].yoffset != 0)
+				fprintf(fp, "currentpoint %d sub moveto ",
+					textpool[i].yoffset);
 		} else {
 			fprintf(fp, "\n");
 			if (textpool[i].font) {
@@ -1426,6 +1492,7 @@
 	}
 	textpool[ntextpool].pfx = pfx;
 	textpool[ntextpool].xoffset = offset;
+	textpool[ntextpool].yoffset = char_off;
 	textpool[ntextpool].xsiz = linewidth - offset;
 	textpool[ntextpool].size = fontsize;
 	textpool[ntextpool].font = curfont[ctype];
@@ -1973,6 +2040,10 @@
 	char *progname;
 	static char pathbuf[MAXPATHLEN];
 
+#ifdef USE_SETLOCALE
+        setlocale(LC_CTYPE, "");
+#endif
+
 	progname = argv[0];
 
 	/* set default paper size */
@@ -2190,7 +2261,21 @@
 			font->psfont, font->font);
 	}
 	if (font->lang == ASCII && encoding) {
-		fprintf(fp,
+		/*
+		 * Symbol font does not need latin1-encoding
+		 */
+		if (strcmp(font->psfont, "Symbol") == 0) {
+			fprintf(fp,
+				"/%s%s\n"
+				"	/%s findfont\n"
+				"		dup length dict begin\n"
+				"		{1 index /FID ne {def} {pop "
+				"pop} ifelse} forall\n"
+				"	currentdict end\n"
+				"definefont pop\n",
+				fontstring(font), "t", font->psfont);
+		} else {
+			fprintf(fp,
 "/%s%s\n"
 "	/%s findfont\n"
 "		dup length dict begin\n"
@@ -2199,6 +2284,8 @@
 "	currentdict end\n"
 "definefont pop\n",
 			fontstring(font), "t", font->psfont, encoding->defstr);
+		}
+
 		fprintf(fp, "/%s {/%s%s findfont exch scalefont setfont} def\n",
 			fontstring(font), fontstring(font), "t");
 	} else {
Index: kit/scanner.l
diff -u kit/scanner.l:1.23 kit/scanner.l:1.24
--- kit/scanner.l:1.23	Sat Apr 12 07:05:42 2003
+++ kit/scanner.l	Fri Sep 12 11:04:55 2003
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: scanner.l,v 1.23 2003/04/11 22:05:42 nishida Exp $
+ * $Id: scanner.l,v 1.24 2003/09/12 02:04:55 nishida Exp $
  */
 /*
  * partly derived from lbl libpcap source code, which has the following
@@ -166,6 +166,10 @@
 (VALIGN|valign)	return KW_VALIGN;
 (AREA|area)	return KW_AREA;
 (OPAQUE|opaque)	return KW_OPAQUE;
+(SUP|sup)	return KW_SUP;
+(SUB|sub)	return KW_SUB;
+(SETSUP|setsup)	return KW_SETSUP;
+
 
 [ \n\t]		;
 ","		return COMMA;
Index: kit/tfont.c
diff -u kit/tfont.c:1.43 kit/tfont.c:1.44
--- kit/tfont.c:1.43	Sat Jan 12 10:56:25 2002
+++ kit/tfont.c	Fri Sep 12 11:04:55 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: tfont.c,v 1.43 2002/01/12 01:56:25 nishida Exp $
+ * $Id: tfont.c,v 1.44 2003/09/12 02:04:55 nishida Exp $
  */
 
 #include "mgp.h"
@@ -627,6 +627,18 @@
 					TT_Get_CharMap(face[tfcuridx], i, &char_map);
 					return TT_Char_Index(char_map, (short) code);
 				}
+#endif
+				else {
+					/* symbol font */
+					if (platform == 3 && encoding == 0) {
+						code |= 0xf000;
+						TT_Get_CharMap(face[tfcuridx],
+								i, &char_map);
+						return TT_Char_Index(char_map,
+								code);
+					}
+				}
+#ifdef FREETYPE_CHARSET16
 			}
 		}
 #endif
Index: kit/x11.c
diff -u kit/x11.c:1.29 kit/x11.c:1.30
--- kit/x11.c:1.29	Mon May 19 16:29:45 2003
+++ kit/x11.c	Fri Sep 12 11:04:55 2003
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: x11.c,v 1.29 2003/05/19 07:29:45 nishida Exp $
+ * $Id: x11.c,v 1.30 2003/09/12 02:04:55 nishida Exp $
  */
 
 #include "mgp.h"
@@ -199,6 +199,10 @@
 	}
 
 	char_size[0] = window_height * DEFAULT_CHARSIZE / 100;
+	nonscaled_size[0] = char_size[0];
+	sup_off = DEFAULT_SUPOFF;
+	sub_off = DEFAULT_SUBOFF;
+	sup_scale = DEFAULT_SUPSCALE;
 	(void)get_color(DEFAULT_FORE, &fore_color[0]);
 	ctrl_color[0] = fore_color[0];
 
@@ -231,8 +235,8 @@
 		(window_width < 0) ? 0 : window_width,
 		(window_height < 0) ? 0 : window_height,
 		0, depth, InputOutput, visual, mask, &xsa);
-	XStoreName(display, window, "MagicPoint");
-	XSetIconName(display, window, "MagicPoint");
+	XStoreName(display, window, mgp_wname);
+	XSetIconName(display, window, mgp_wname); 
 	XSetClassHint(display, window, &res);
 	pixmap = XCreatePixmap(display, window, xa.width, xa.height, depth);
 	maskpix = XCreatePixmap(display, window, xa.width, xa.height, depth);
Index: kit/contrib/latex2eps.sh
diff -u /dev/null kit/contrib/latex2eps.sh:1.1
--- /dev/null	Mon Sep 15 05:10:03 2003
+++ kit/contrib/latex2eps.sh	Fri Sep 12 11:04:56 2003
@@ -0,0 +1,69 @@
+#! /bin/sh
+#
+# latex2eps.sh - translates latex math formula to EPS
+#
+# Expected usage:
+#   %filter "latex2eps.sh eqn"
+#   \begin{displaymath}
+#   \frac{1}{x+y}
+#   \end{displaymath}
+#   %endfilter
+#   %image "eqn.eps" 250x200
+#
+# additional style can be used with option -sty, eg.
+#   latex2eps -sty pslatex -sty color eqn
+#
+# History:
+#   18.03.2003  first creation
+#   06.03.2003  support for subdirs added
+#
+
+#parse command line options
+STYLES=""
+while [ $# -gt 0 ]
+do
+	case "$1" in
+	# additional styles
+	-sty) STYLES="$STYLES $2"; shift;;
+	# temporary filename (without .eps suffix)
+	*)    tmp=$1;;
+	esac
+	shift
+done
+
+# in case a different directory is given:
+datadir="`dirname $tmp`"
+if [ ! -z "$datadir" ]
+then
+	tmp="`basename $tmp`"
+	cd "$datadir"
+fi
+
+# target TeX file and temporary new file
+tex=$tmp.tex
+texnew=$tmp.tex.new
+
+# write new TeX file
+echo '\documentclass[fleqn]{article}' > $texnew
+echo '\usepackage[latin1]{inputenc}' >> $texnew
+for sty in $STYLES
+do
+	echo "\usepackage{$sty}" >> $texnew
+done
+echo '\begin{document}' >> $texnew
+echo '\thispagestyle{empty}' >> $texnew
+echo '\mathindent0cm' >> $texnew
+echo '\parindent0cm' >> $texnew
+cat >> $texnew
+echo '\end{document}' >> $texnew
+
+# exit when no change
+test -e $tmp.eps && test -e $tex && diff $tex $texnew >/dev/null 2>&1 && {
+	/bin/rm -f $texnew
+	exit 0; }
+
+# otherwise process TeX file
+mv $texnew $tex
+latex $tex > /dev/null 2> /dev/null
+dvips -q -E $tmp.dvi -o $tmp.eps
+/bin/rm -f $tmp.log $tmp.dvi $tmp.aux
Index: kit/contrib/mgp-mode-cd.el
diff -u /dev/null kit/contrib/mgp-mode-cd.el:1.1
--- /dev/null	Mon Sep 15 05:10:03 2003
+++ kit/contrib/mgp-mode-cd.el	Fri Sep 12 11:04:56 2003
@@ -0,0 +1,291 @@
+;; mgp-mode-cd.el - An Emacs major-mode for editing MagicPoint files.
+
+;; Filename: mgp-mode-cd.el
+;; Author:   Christoph Dalitz
+;; Version:  1.6
+;; License:  GNU General Public License
+;; Homepage: http://lionel.kr.hsnr.de/~dalitz/data/software/mgp/mgp.html
+
+;; Abstract:
+;;
+;;  This mode is called "mgp-mode-cd" in order to distinguish it from the 
+;;  official "mgp-mode" that is shipped with MagicPoint. In contrast to the
+;;  official "mgp-mode", which I find too complicated for the average user,
+;;  this mode focuses on ease of use: all actions are accessible from a
+;;  self-explanatory main menu entry. Moreover this mode supports the
+;;  option to preview only the current page.
+
+;; Installation:
+;;
+;;  1) Optionally, byte-compile this file
+;;  2) Put this file in a directory Emacs can find
+;;  3) Tell Emacs when to load this file
+;;  4) Customize some variables for your system
+;;
+;; ad 1)
+;;  Byte-compilation speeds up the load time for this mode
+;;  and is therefore recommended. Just load this file into
+;;  Emacs and select "Byte-compile This File" from the
+;;  "Emacs-Lisp" main menu. This will create the compiled
+;;  file with the extension "elc".
+;;
+;; ad 2)
+;;  The directories that Emacs searches are given by the 
+;;  load-path variable, which you can query within Emacs with
+;;     ESC-x describe-variable RET load-path Ret
+;;  To add a directory (eg. ~/.emacs) to load-path, add 
+;;  the following code to your $HOME/.emacs file:
+;;     (add-to-list 'load-path "~/elisp")
+;;
+;; ad 3)
+;;  Add the following lines to your $HOME/.emacs file:
+;;     (autoload 'mgp-mode "mgp-mode-cd" "MGP mode." t)
+;;     (add-to-list 'auto-mode-alist '("\\.mgp$" . mgp-mode))
+;;  The first line tells Emacs to load mgp-mode-cd.elc or
+;;  mgp-mode-cd.el when the command 'mgp-mode' is called.
+;;  The second line tells emacs to invoke the command 'mgp-mode'
+;;  when a file with a name ending on ".mgp" is opened.
+;;
+;; ad 4)
+;;  Some variables might need adjustment to your local system
+;;  environment. You can do it in your $HOME/.emacs file with 
+;;  commands like
+;;     (setq mgp-command     "mgp -x vflib")
+;;     (setq mgp-tmpfile     "/tmp/preview.mgp")
+;;     (setq mgp-helpcommand "zcat /usr/share/doc/mgp/SYNTAX.gz | xless")
+;;  You can also set these variables interactively from the
+;;  entry "Options" in the "MGP" main menu that is created
+;;  when mgp-mode is entered.
+
+;; History
+;;
+;;   01.05.2001  first creation for GNU Emacs
+;;   27.02.2002  added installation instructions
+;;               added options menu for setting of mgp command line
+;;               bugfix preview-file when cursor in header
+;;   01.03.2002  bugfix in mark-page for last page
+;;   10.05.2002  new option "Syntax Help" in MGP main menu
+;;   30.05.2002  "Syntax Help" now displayed asynchronously
+;;               ported to Xemacs
+;;   12.06.2002  workaround for undefined builtin-face in Xemacs
+;;               preview-page now also works when cursor in preamble
+;;   12.12.2002  added support for ispell
+
+;; List of functions called when mgp-mode is entered
+(defcustom mgp-mode-hook '()
+  "*Hook for customising `mgp-mode'."
+  :type 'hook
+  :group 'Mgp)
+
+;; custom variables
+(defcustom mgp-command "mgp -x vflib"
+  "mgp command line.
+Must be adjusted according to the compilation options,
+eg. 'mgp -x vflib' when mgp is compile with vflib, but vflib 
+is not installed."
+  :group 'Mgp)
+(defcustom mgp-tmpfile "/tmp/page.mgp"
+  "Temporary file generated when only parts are previewed."
+  :group 'Mgp)
+(defcustom mgp-helpcommand "zcat /usr/share/doc/mgp/SYNTAX.gz | xless"
+  "Command for display of MGP syntax documentation."
+  :group 'Mgp)
+
+;; shortcut key bindings
+(defvar mgp-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c C-b") 'mgp-preview-file)
+    (define-key map (kbd "C-c C-p") 'mgp-preview-page)
+    (define-key map (kbd "C-c C-c") 'mgp-comment-region)
+    (define-key map (kbd "C-c C-u") 'mgp-uncomment-region)
+    (define-key map (kbd "C-c C-m") 'mgp-mark-page)
+    map)
+  "Mode map used for `mgp-mode'.")
+
+;; main menu entry
+(easy-menu-define
+ mgp-mode-menu mgp-mode-map
+ "Menu for `mgp-mode'."
+ '("MGP"
+   ["Preview Buffer" mgp-preview-file ]
+   ["Preview Page" mgp-preview-page ]
+   ;; automatic menu deactivation when no region marked
+   ;; only works with GNU Emacs and crashes (!) Xemacs
+   ;; ["Comment Region" mgp-comment-region (region-beginning) ]
+   ;; ["Uncomment Region" mgp-uncomment-region (region-beginning) ]
+   ["Comment Region" mgp-comment-region ]
+   ["Uncomment Region" mgp-uncomment-region ]
+   ["Mark Page" mgp-mark-page ]
+   ["Syntax Help" (start-process-shell-command "bla" nil mgp-helpcommand) ]
+   ["-" nil ]
+   ["Options" (customize-group "Mgp") ]
+))
+
+;; syntax table 
+;; currently not used; see comment below font-lock-defaults
+(defvar mgp-mode-syntax-table 
+  (let ((table (make-syntax-table)))
+    ;; comments start with # and end with newline
+    (modify-syntax-entry ?\# "<" table)
+    (modify-syntax-entry 10  ">" table)
+    (modify-syntax-entry 12  ">" table)
+    table)
+  "Syntax table used in 'mgp-mode'.")
+
+(defvar mgp-mode-font-lock-keywords nil
+  "Mgp keywords used by font-lock.")
+(if mgp-mode-font-lock-keywords ()
+  (let ()
+    (setq mgp-mode-font-lock-keywords
+	  (list 
+       ;; comments
+	   (cons "^#.*" 'font-lock-comment-face)
+	   (cons "^%%.*" 'font-lock-comment-face)
+       ;; new page
+	   (cons "^%page" 'font-lock-string-face)
+       ;; filters
+	   (cons "^%filter.*" 'font-lock-builtin-face)
+	   (cons "^%endfilter.*" 'font-lock-builtin-face)
+       ;; other format parameters
+	   (cons "^%.*" 'font-lock-function-name-face)
+	  ))
+))
+
+;; function definitions
+(defun mgp-comment-region (start end)
+  "Comments out the current region with '# '."
+  (interactive "r")
+  (goto-char end) (beginning-of-line) (setq end (point))
+  (goto-char start) (beginning-of-line) (setq start (point))
+  (let ()
+  (save-excursion
+	(save-restriction
+	  (narrow-to-region start end)
+	  (while (not (eobp))
+		(insert "# ")
+		(forward-line 1)))))
+)
+(defun mgp-uncomment-region (start end)
+  "Remove '# ' comments from current region."
+  (interactive "r")
+  (goto-char end) (beginning-of-line) (setq end (point))
+  (goto-char start) (beginning-of-line) (setq start (point))
+  (let ((prefix-len '2))
+  (save-excursion
+	(save-restriction
+	  (narrow-to-region start end)
+	  (while (not (eobp))
+		(if (string= "# "
+					 (buffer-substring
+					  (point) (+ (point) prefix-len)))
+			(delete-char prefix-len))
+		(forward-line 1)))))
+)
+(defun mgp-preview-file ()
+  "Previews current file with mgp.
+Starts at the page where the cursor currently is."
+  (interactive)
+  (save-buffer)
+  (save-excursion
+    (let ((pnum (string-to-number (how-many "^%page"))))
+      ;; calculate current page number
+      (goto-char (point-min))
+      (setq pnum (- (string-to-number (how-many "^%page")) pnum))
+	  (when (< pnum 1) (setq pnum 1))
+      ;;(y-or-n-p (format "Pages %d" pnum))
+      (shell-command
+       (format "%s -p %d %s" mgp-command pnum
+               (shell-quote-argument buffer-file-name)))
+      ))
+)
+(defun mgp-mark-page ()
+  "Marks the current page.
+In mgp-mode, one page is one paragraph. Thus you can mark
+a page with `mark-paragraph' as well."
+  (interactive)
+  (mark-paragraph)
+)
+(defun mgp-preview-page ()
+  "Previews current page with mgp."
+  (interactive)
+  (save-buffer)
+  ;; write preamble...
+  (save-excursion
+	(goto-char (point-min))
+	(mgp-mark-page)
+	(write-region (region-beginning) (region-end) mgp-tmpfile)
+	)
+  ;; ...and current page
+  (save-excursion
+	;; move to first page when cursor before first page
+    (let ((pnum (string-to-number (how-many "^%page"))))
+	  (save-excursion
+		(goto-char (point-min))
+		(setq pnum (- (string-to-number (how-many "^%page")) pnum)))
+	  (when (< pnum 1) (re-search-forward "^%page" nil t)))
+	(mgp-mark-page)
+	(append-to-file (region-beginning) (region-end) mgp-tmpfile)
+	(shell-command (format "%s %s" mgp-command mgp-tmpfile))
+	)
+)
+
+;;;###autoload
+(defun mgp-mode ()
+  "Major mode for editing mgp2 source.
+Comments etc. are highlighted with font-lock. There are also a 
+number of commands that make editing and working with MGP files 
+more convenient. These commands are available from the main menu 
+`MGP' or via the following shortcuts:
+
+\\[mgp-preview-file]	- Run mgp on the current file.
+\\[mgp-comment-region]	- Comments out the current region.
+\\[mgp-uncomment-region]	- Uncomments the current region.
+\\[mgp-mark-page]	- Marks the current page (== paragraph).
+"
+  (interactive)
+  (kill-all-local-variables)
+  (setq major-mode 'mgp-mode)
+  (setq mode-name "mgp")
+
+  (use-local-map mgp-mode-map)
+
+  ;; workarounds for xemacs:
+  ;; - menu must be explicitly added
+  ;; - xemacs uses preprocessor-face instead of builtin-face
+  (easy-menu-add mgp-mode-menu mgp-mode-map)
+  (if (string-match "XEmacs\\|Lucid" emacs-version)
+	  (progn (make-face 'font-lock-builtin-face)
+			 (copy-face 'font-lock-preprocessor-face 'font-lock-builtin-face)))
+
+  ;; syntax table is not used (see below)
+  (set-syntax-table mgp-mode-syntax-table)
+  (make-local-variable 'font-lock-defaults)
+  (setq font-lock-defaults '(mgp-mode-font-lock-keywords
+				 t t ((?_ . "w") (?. . "w"))))
+  ;;            ^^^
+  ;; (otherwise syntax table wins and keywords are ignored!)
+
+  ;; paragraph == page
+  (make-local-variable 'paragraph-start)
+  (setq paragraph-start "[%#]?.*%page") 
+
+  ;; additional options
+
+  ;;(make-local-variable 'require-final-newline)
+  ;;(setq require-final-newline t)
+
+  ;;(setq blink-matching-paren t)
+
+  ;; TAB must insert TAB rather than Spaces
+  (setq indent-tabs-mode t)
+
+  ;; let ispell skip %-directives
+  (make-local-variable 'ispell-skip-region-alists)
+  (add-to-list 'ispell-skip-region-alist (list "^%.*$"))
+
+  ;; case insensitive pattern matching
+  (setq font-lock-keywords-case-fold-search t)
+  (put 'mgp-mode 'font-lock-keywords-case-fold-search t)
+
+  (run-hooks 'mgp-mode-hook)
+)
Index: kit/image/gif.h
diff -u kit/image/gif.h:1.2 kit/image/gif.h:removed
--- kit/image/gif.h:1.2	Mon Dec 28 17:23:03 1998
+++ kit/image/gif.h	Mon Sep 15 05:10:08 2003
@@ -1,72 +0,0 @@
-/* gif.h:
- *
- * gifin.h
- * kirk johnson
- * november 1989
- * external interface to gifin.c
- *
- * Copyright 1989 Kirk L. Johnson (see the included file
- * "kljcpyrght.h" for complete copyright information)
- */
-
-/*
- * gifin return codes
- */
-#define GIFIN_SUCCESS       0   /* success */
-#define GIFIN_DONE          1   /* no more images */
-
-#define GIFIN_ERR_BAD_SD   -1   /* bad screen descriptor */
-#define GIFIN_ERR_BAD_SEP  -2   /* bad image separator */
-#define GIFIN_ERR_BAD_SIG  -3   /* bad signature */
-#define GIFIN_ERR_EOD      -4   /* unexpected end of raster data */
-#define GIFIN_ERR_EOF      -5   /* unexpected end of input stream */
-#define GIFIN_ERR_FAO      -6   /* file already open */
-#define GIFIN_ERR_IAO      -7   /* image already open */
-#define GIFIN_ERR_NFO      -8   /* no file open */
-#define GIFIN_ERR_NIO      -9   /* no image open */
-
-/*
- * colormap indices 
- */
-
-#define GIF_RED  0
-#define GIF_GRN  1
-#define GIF_BLU  2
-
-/*
- * typedef BYTE for convenience
- */
-
-typedef unsigned char BYTE;
-
-static int gifin_open_file();
-static int gifin_open_image();
-static int gifin_get_pixel();
-#if 0
-static int gifin_close_image();
-#endif
-static int gifin_close_file();
-static int gifin_load_cmap();
-static int gifin_skip_extension();
-static int gifin_read_data_block();
-static int gifin_push_string();
-static void gifin_add_string();
-static void gifin_fatal();
-
-/* #defines, typedefs, and such
- */
-
-#define GIF_SIG      "GIF87a"
-#define GIF_SIG_89   "GIF89a"
-#define GIF_SIG_LEN  6          /* GIF signature length */
-#define GIF_SD_SIZE  7          /* GIF screen descriptor size */
-#define GIF_ID_SIZE  9          /* GIF image descriptor size */
-
-#define GIF_SEPARATOR   ','     /* GIF image separator */
-#define GIF_EXTENSION   '!'     /* GIF extension block marker */
-#define GIF_TERMINATOR  ';'     /* GIF terminator */
-
-#define STAB_SIZE  4096         /* string table size */
-#define PSTK_SIZE  4096         /* pixel stack size */
-
-#define NULL_CODE  -1           /* string table null code */
Index: kit/sample/cloud.gif
Index: kit/sample/dad.gif
Index: kit/sample/dns-jp.mgp
diff -u kit/sample/dns-jp.mgp:1.5 kit/sample/dns-jp.mgp:removed
--- kit/sample/dns-jp.mgp:1.5	Fri Sep  4 21:33:18 1998
+++ kit/sample/dns-jp.mgp	Mon Sep 15 05:10:08 2003
@@ -1,130 +0,0 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
-%%	This file is automatically created from the file
-%%	main.pre modified at Fri Jan 23 14:31:24 1998
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
-%include "default.mgp"
-%% "noop" cancels definitions in default.mgp
-%default 1 left, size 7, fore "light yellow", back "blue4", font "standard", ccolor "white", vgap 35
-%default 2 noop
-%default 3 fore "white", bar "gray70", vgap 10
-%default 4 noop
-%tab 1 noop
-%tab 2 noop
-%tab 3 noop
-%%%
-%page
-%nodefault
-%fore "red", back "blue4", size 9, vgap 15
-%center, fore "yellow", font "thick"
-%ccolor "white"
-
-
-
-Root DNS `M' $B$K$D$$$F(B
-
-%size 6, fore "red", font "thick"
-$B2CF#(B   $BO/(B
-
-%size 5, fore "white", font "standard"
-$BEl5~Bg3XBg7?7W;;5!%;%s%?!<(B
-
-
-%font "typewriter"
-kato@wide.ad.jp
-%font "standard"
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B7P0^(B (1)
-%fore "red", size 6, font "thick"
-   $B!y(B Root DNS
-%fore "white", size 5, font "standard"
-       $B!&(B $B#9Bf$G1?MQ(B
-%fore "white", size 5, font "standard"
-          $B!](B $B#8Bf$,(B US
-          $B!](B Stockholm $B$K#1Bf(B
-%fore "white", size 5, font "standard"
-       $B!&(B $B:GBg$G#1#3Bf(B
-%fore "white", size 5, font "standard"
-          $B!](B $B%Q%1%C%HD9$N@)Ls(B
-%fore "red", size 6, font "thick"
-   $B!y(B Root DNS $B$N1?MQ4p=`(B
-%fore "white", size 5, font "standard"
-       $B!&(B RFC 2010
-       $B!&(B gTLD $B$H$N4X78(B
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B7P0^(B (2)
-%fore "red", size 6, font "thick"
-   $B!y(B IEPG $B$G3HD%$r8!F$(B
-   $B!y(B $B%h!<%m%C%QCO0h(B
-%fore "white", size 5, font "standard"
-       $B!&(B LINX $B$K?7@_(B : 1997 $BG/(B 4 $B7n(B
-%fore "white", size 5, font "standard"
-          $B!](B RIPE/NCC $B$,4IM}(B
-          $B!](B `K'
-%fore "red", size 6, font "thick"
-   $B!y(B $B%"%8%"B@J?MNCO0h(B
-%fore "white", size 5, font "standard"
-       $B!&(B NSPIXP-2 $B!'(B 1997 $BG/(B 8 $B7n(B
-%fore "white", size 5, font "standard"
-          $B!](B WIDE $B$,4IM}(B
-          $B!](B `M'
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  `M'
-%fore "red", size 6, font "thick"
-   $B!y(B $B9=@.(B
-%fore "white", size 5, font "standard"
-       $B!&(B $B#2Bf$N(B PentiumPro 200MHz
-       $B!&(B Primary/Backup$B!"(B $B<+F0@Z$jBX$((B
-%fore "red", size 6, font "thick"
-   $B!y(B Root-only $B%5!<%P(B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-202.12.27.33
-%font "standard"
-       $B!&(B 400 $B!A(B 500 query/sec
-%fore "red", size 6, font "thick"
-   $B!y(B $B1?MQ4IM}(B
-%fore "white", size 5, font "standard"
-       $B!&(B WIDE $B$*$h$S(B ISP $BM-;V(B
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B$*4j$$(B
-%fore "red", size 6, font "thick"
-   $B!y(B $B:G?7$N(B root.cache $B$NF~$l49$((B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-1997082200
-%fore "red", size 6, font "thick"
-   $B!y(B Named $B$N99?7(B
-%fore "white", size 5, font "standard"
-       $B!&(B 4.9.6/8.8.1
-%fore "red", size 6, font "thick"
-   $B!y(B $BM7$P$J$$$G!'(B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-ping/traceroute
-%font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-telnet/spray/...
-%fore "red", size 6, font "thick"
-   $B!y(B Thanks to
-%fore "white", size 5, font "standard"
-       $B!&(B $BF|K\(B Cisco/$BB?$/$N(B ISP
-       $B!&(B `M' $B4IM}%0%k!<%W(B
Index: kit/sample/mgp-old1.gif
Index: kit/sample/mgp-old2.gif
Index: kit/sample/mgp-old3.gif
Index: kit/sample/mgp1.gif
Index: kit/sample/mgp2.gif
Index: kit/sample/mgp3.gif
Index: kit/sample/v6header.gif
