Index: trunk/Ohana/src/libkapa/src/DrawRotString.c
===================================================================
--- trunk/Ohana/src/libkapa/src/DrawRotString.c	(revision 39594)
+++ trunk/Ohana/src/libkapa/src/DrawRotString.c	(revision 39595)
@@ -88,5 +88,5 @@
     if (!code && !protect) {
       /* subscript, starts with _ */
-      if (N == 94) {
+      if (N == 94) { // underscore
 	SetRotFont (currentname, (int)(0.8*currentsize));
 	currentfont = GetRotFontData (&currentscale);
@@ -95,5 +95,5 @@
       }
       /* superscript, starts with ^ */
-      if (N == 95) { 
+      if (N == 95) { // caret
 	SetRotFont (currentname, (int)(0.8*currentsize));
 	currentfont = GetRotFontData (&currentscale);
@@ -102,5 +102,5 @@
       }
       /* normal script, starts with | */
-      if (N == 124) {
+      if (N == 124) { // pipe
 	SetRotFont (currentname, basesize);
 	currentfont = GetRotFontData (&currentscale);
@@ -108,9 +108,132 @@
 	continue;
       }
-      if (N == 92) {
+      if (N == 92) { // backslash
 	code = TRUE;
 	continue;
       } 
-      if (N == 38) {
+      if (N == 38) { // ampersand
+	if (string[i+1] == 'h') {
+	  SetRotFont ("helvetica", currentsize);
+	  currentfont = GetRotFontData (&currentscale);
+	}
+	if (string[i+1] == 't') {
+	  SetRotFont ("times", currentsize);
+	  currentfont = GetRotFontData (&currentscale);
+	}
+	if (string[i+1] == 'c') {
+	  SetRotFont ("courier", currentsize);
+	  currentfont = GetRotFontData (&currentscale);
+	}
+	if (string[i+1] == 's') {
+	  SetRotFont ("symbol", currentsize);
+	  currentfont = GetRotFontData (&currentscale);
+	}
+	i++;
+	continue;
+      }
+    }
+    code = FALSE;
+
+    bitmap = currentfont[N].bits;
+    dx = currentfont[N].dx;
+    dy = currentfont[N].dy;
+    X = x + (int)(Xoff*cs - Yoff*sn) + (int)(currentscale*currentfont[N].ascent*sn);
+    Y = y + (int)(Xoff*sn + Yoff*cs) - (int)(currentscale*currentfont[N].ascent*cs);
+    DrawRotBitmap (X, Y, dx, dy, bitmap, TRUE, angle, currentscale);
+    Xoff += 1 + (int)(currentscale*dx + 0.5);
+  }
+  SetRotFont (basename, basesize);
+  return (TRUE);
+}
+
+/* 
+   latex interpretation rules:
+   \word = special character
+   interpretation is LaTeX math mode
+   
+
+ */
+
+int DrawRotText_Latex (int x, int y, char *string, int pos, double angle) {
+
+  unsigned char *bitmap;
+  char *currentname, basename[64]; 
+  int dy, dx, N, X, Y, code, protect;
+  int dX, Xoff, dY, Yoff, YoffBase;
+  int currentsize, basesize;
+  double cs, sn, currentscale;
+  RotFont *currentfont;
+
+  currentname = GetRotFont (&currentsize);
+  currentfont = GetRotFontData (&currentscale);
+  strcpy (basename, currentname);
+  basesize = currentsize;
+
+  /* strip leading WHITESPACE */
+  stripwhite (string);
+  if (*string == 0) return (FALSE);
+  
+  /* compute string length */
+  cs = cos(angle*RAD_DEG);
+  sn = sin(angle*RAD_DEG);
+  dX = RotStrlen (string);
+  dY = currentfont[65].ascent;
+
+  /* apply appropriate offset */
+  Xoff = Yoff = 0;
+  switch (pos) {
+  case 0: Xoff =     -dX; Yoff = dY; break;
+  case 1: Xoff = -0.5*dX; Yoff = dY; break;
+  case 2: Xoff =       0; Yoff = dY; break;
+  case 3: Xoff =     -dX; Yoff = 0.5*dY; break;
+  case 4: Xoff = -0.5*dX; Yoff = 0.5*dY; break;
+  case 5: Xoff =       0; Yoff = 0.5*dY; break;
+  case 6: Xoff =     -dX; Yoff = 0; break;
+  case 7: Xoff = -0.5*dX; Yoff = 0; break;
+  case 8: Xoff =       0; Yoff = 0; break;
+  }
+
+  code = FALSE;
+  protect = FALSE;
+
+  YoffBase = Yoff;
+  /* draw characters one-by-one */
+  unsigned int i;
+  for (i = 0; i < strlen(string); i++) {
+    N = (int)(string[i]);
+    if ((N < 0) || (N >= NROTCHARS)) continue;
+
+    if (N == 39) { // single-quote
+      protect = protect ? FALSE : TRUE;
+    } 
+
+    /* check for special characters */
+    if (!code && !protect) {
+      /* subscript, starts with _ */
+      if (N == 94) { // underscore
+	SetRotFont (currentname, (int)(0.8*currentsize));
+	currentfont = GetRotFontData (&currentscale);
+	Yoff -= 0.5*currentscale*dY;
+	continue;
+      }
+      /* superscript, starts with ^ */
+      if (N == 95) { // caret
+	SetRotFont (currentname, (int)(0.8*currentsize));
+	currentfont = GetRotFontData (&currentscale);
+	Yoff += 0.5*currentscale*dY;
+	continue;
+      }
+      /* normal script, starts with | */
+      if (N == 124) { // pipe
+	SetRotFont (currentname, basesize);
+	currentfont = GetRotFontData (&currentscale);
+	Yoff = YoffBase;
+	continue;
+      }
+      if (N == 92) { // backslash
+	code = TRUE;
+	continue;
+      } 
+      if (N == 38) { // ampersand
 	if (string[i+1] == 'h') {
 	  SetRotFont ("helvetica", currentsize);
