This is plstrl.c in view mode; [Download] [Up]
/* Computes the length of a string in mm, including escape sequences */ #include "plplot.h" #include <math.h> double plstrl(string) char *string; { short int *symbol; SCHAR *xygrid; int ch, i, length, level; double width, xorg, dscale, scale, def, ht; double xscl, xoff, yscl, yoff; width = 0.0; gchr(&def,&ht); dscale = 0.05*ht; scale = dscale; gmp(&xscl,&xoff,&yscl,&yoff); pldeco(&symbol,&length,string); xorg = 0.0; level = 0; for (i=0; i<length; i++) { ch = symbol[i]; if (ch == -1) { level = level + 1; scale = dscale * pow(0.75,(double)ABS(level)); } else if (ch == -2) { level = level - 1; scale = dscale * pow(0.75,(double)ABS(level)); } else if (ch == -3) xorg = xorg - width * scale; else if (ch == -4 || ch == -5) ; else { if (plcvec(ch,&xygrid)) { width = xygrid[3] - xygrid[2]; xorg = xorg + width*scale; } } } return((double)xorg); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.