ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/src/plfont.c

This is plfont.c in view mode; [Download] [Up]

#include "plplot.h"
#include <stdio.h>

#ifdef AMIGA
#define XFONT "PLFONTS:plxtnd.font"
#define SFONT "PLFONTS:plstnd.font"
#endif

void plfont(ifont)
int ifont;
{
      int ifnt,icol;
      int level;

      glev(&level);
      if (level < 1) plexit("Please call plstar before calling plfont.");

      if (ifont < 1 || ifont > 4) plexit("Invalid font in plfont.");
      gatt(&ifnt,&icol);
      satt(ifont,icol);
}

short int *fntlkup;
short int *fntindx;
SCHAR *fntbffr;
short int numberfonts, numberchars;
short int indxleng;

static short fontloaded=0;

/* Loads either the standard or extended font */
void plfntld(fnt)
int fnt;
{
   static short charset;
   short bffrleng;
   FILE *fontfile;
   int level;

   glev(&level);
   if (level < 1)  plexit("Please call plstar before calling plfontld.");

   if(fontloaded) {
      if(charset == fnt) return;
      free((VOID *)fntindx);
      free((VOID *)fntbffr);
      free((VOID *)fntlkup);
   }

   charset = fnt;

   if(fnt)
      fontfile = fopen(XFONT,"r");
   else
      fontfile = fopen(SFONT,"r");

   if(!fontfile)
      plexit("Error opening font file.\n");
   else
      fontloaded = 1;

   fread((char *)&bffrleng,sizeof(short),1,fontfile);
   numberfonts = bffrleng/256;
   numberchars = bffrleng & 0xff;
   bffrleng = numberfonts*numberchars;
   fntlkup = (short int *)malloc(bffrleng*sizeof(short int));
   if(!fntlkup)
      plexit("Out of memory while allocating font buffer.\n");
   fread((char *)fntlkup,sizeof(short int),bffrleng,fontfile);

   fread((char *)&indxleng,sizeof(short),1,fontfile);
   fntindx = (short int *)malloc(indxleng*sizeof(short int));
   if(!fntindx)
      plexit("Out of memory while allocating font buffer.\n");
   fread((char *)fntindx,sizeof(short int),indxleng,fontfile);

   fread((char *)&bffrleng,sizeof(short),1,fontfile);
   fntbffr = (SCHAR *)malloc(2*bffrleng*sizeof(SCHAR));
   if(!fntbffr)
      plexit("Out of memory while allocating font buffer.\n");
   fread((char *)fntbffr,sizeof(SCHAR),2*bffrleng,fontfile);

   fclose(fontfile);
}

void plfontrel()
{
   if(fontloaded) {
      free((VOID *)fntindx);
      free((VOID *)fntbffr);
      free((VOID *)fntlkup);
      fontloaded=0;
   }
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.