IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 27, 2005, 9:22:01 PM (21 years ago)
Author:
eugene
Message:

fixed up RotFont stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa/graph/DrawRotString.c

    r5610 r5611  
    11# include "Ximage.h"
    2 # include "alphabet.h"
    3 
     2
     3# define NROTCHARS 256
    44# define XPROC(x,y) (scale*(cs*((x) - x0) - sn*((y) - y0)) + X0)
    55# define YPROC(x,y) (scale*(cs*((y) - y0) + sn*((x) - x0)) + Y0)
     
    88int DrawRotText (int x, int y, char *string, int pos, double angle) {
    99
    10   char *c, *bitmap, basefont[64];
     10  unsigned char *bitmap;
     11  char *currentname, basename[64], *c;
    1112  int i, dy, dx, N, X, Y, code;
    12   int dX, Xoff, dY, Yoff, YoffBase, basesize;
    13   double cs, sn;
     13  int dX, Xoff, dY, Yoff, YoffBase;
     14  int currentsize, basesize;
     15  double cs, sn, currentscale;
     16  RotFont *currentfont;
     17
     18  currentname = GetRotFont (&currentsize);
     19  currentfont = GetRotFontData (&currentscale);
     20  strcpy (basename, currentname);
     21  basesize = currentsize;
    1422
    1523  /* strip leading whitespace */
     
    2129  sn = sin(angle*RAD_DEG);
    2230  dX = RotStrlen (c);
    23   dY = activefont[65].ascent;
     31  dY = currentfont[65].ascent;
    2432
    2533  /* apply appropriate offset */
     
    3947  code = FALSE;
    4048
    41   strcpy (basefont, currentname);
    42   basesize = currentsize;
    43 
    4449  YoffBase = Yoff;
    4550  /* draw characters one-by-one */
    4651  for (i = 0; i < strlen(c); i++) {
    4752    N = (int)(c[i]);
    48     if ((N < 0) || (N >= NROT)) continue;
     53    if ((N < 0) || (N >= NROTCHARS)) continue;
    4954
    5055    /* check for special characters */
     
    5257      if (N == 94) {
    5358        SetRotFont (currentname, (int)(0.8*currentsize));
    54         Yoff -= 0.5*activescale*dY;
     59        currentfont = GetRotFontData (&currentscale);
     60        Yoff -= 0.5*currentscale*dY;
    5561        continue;
    5662      }
    5763      if (N == 95) {
    5864        SetRotFont (currentname, (int)(0.8*currentsize));
    59         Yoff += 0.5*activescale*dY;
     65        currentfont = GetRotFontData (&currentscale);
     66        Yoff += 0.5*currentscale*dY;
    6067        continue;
    6168      }
    6269      if (N == 124) {
    6370        SetRotFont (currentname, basesize);
     71        currentfont = GetRotFontData (&currentscale);
    6472        Yoff = YoffBase;
    6573        continue;
     
    7280        if (c[i+1] == 'h') {
    7381          SetRotFont ("helvetica", currentsize);
     82          currentfont = GetRotFontData (&currentscale);
    7483        }
    7584        if (c[i+1] == 't') {
    7685          SetRotFont ("times", currentsize);
     86          currentfont = GetRotFontData (&currentscale);
    7787        }
    7888        if (c[i+1] == 'c') {
    7989          SetRotFont ("courier", currentsize);
     90          currentfont = GetRotFontData (&currentscale);
    8091        }
    8192        if (c[i+1] == 's') {
    8293          SetRotFont ("symbol", currentsize);
     94          currentfont = GetRotFontData (&currentscale);
    8395        }
    8496        i++;
     
    88100    code = FALSE;
    89101
    90     bitmap = activefont[N].bits;
    91     dx = activefont[N].dx;
    92     dy = activefont[N].dy;
    93     X = x + (int)(Xoff*cs - Yoff*sn) + (int)(activescale*activefont[N].ascent*sn);
    94     Y = y + (int)(Xoff*sn + Yoff*cs) - (int)(activescale*activefont[N].ascent*cs);
    95     DrawRotBitmap (X, Y, dx, dy, bitmap, TRUE, angle, activescale);
    96     Xoff += 1 + (int)(activescale*dx + 0.5);
     102    bitmap = currentfont[N].bits;
     103    dx = currentfont[N].dx;
     104    dy = currentfont[N].dy;
     105    X = x + (int)(Xoff*cs - Yoff*sn) + (int)(currentscale*currentfont[N].ascent*sn);
     106    Y = y + (int)(Xoff*sn + Yoff*cs) - (int)(currentscale*currentfont[N].ascent*cs);
     107    DrawRotBitmap (X, Y, dx, dy, bitmap, TRUE, angle, currentscale);
     108    Xoff += 1 + (int)(currentscale*dx + 0.5);
    97109  }
    98   SetRotFont (basefont, basesize);
     110  SetRotFont (basename, basesize);
    99111  return (TRUE);
    100112}
    101113
    102 int DrawRotBitmap (int x, int y, int dx, int dy, char *bitmap, int mode, double angle, double scale) {
     114int DrawRotBitmap (int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale) {
    103115
    104116  int ii, jj, byte_line, byte, bit, flag;
Note: See TracChangeset for help on using the changeset viewer.