ftp.nice.ch/pub/next/unix/fonts/ListFonts.N.bs.tar.gz#/ListFonts/ListFonts.c

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

/*
 *	ListFonts - lists fonts on NeXT's
 *	(c) by gfa  <george@nice.usergroup.ethz.ch>
 *	Sat Jan 11 23:37:32 GMT+0100 1992
 */

#include <sys/types.h>
#import <sys/dir.h>
#include <stdio.h>
#include <syslog.h>
#include <strings.h>

#define SIZE 18
#define PAGECLIP  0, 0, 530, 840
#define NUM_PATHS 2
#define PAPER_LENGTH 600

main(int argc, char **argv) {
	
	struct direct  *dp;
	DIR *dirp;
	int  a, b, n, i, k, j;
	char  fontarray[2000][127], fontname[127], 
	pathname[NUM_PATHS][1024] = { "/LocalLibrary/Fonts", "/NextLibrary/Fonts"};
	
	openlog("FontLister", LOG_PID, LOG_DAEMON);

	a = 0;
	for (b = 0; b < NUM_PATHS; b++) {
		dirp = opendir(pathname[b]);
		if (dirp == NULL) {
			syslog(LOG_ERR, "cannot open %s", pathname[b]);
			exit(1);
		}
		for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
			i = 0;
			while (dp->d_name[i] != '.' &&  dp->d_name[i] != '\0') {
				fontname[i] = dp->d_name[i];
				++i;
			}
			fontname[i] = '\0';
			if (dp->d_name[i] == '.' && dp->d_name[i + 1] == 'f' && dp->d_name[i + 2] == 'o' &&
			dp->d_name[i + 3] == 'n' && dp->d_name[i + 4] == 't' && dp->d_name[i + 5] == '\0') {
				strcpy(fontarray[a], fontname);
				++a;
			}
		}	
	}
	qsort(&fontarray[0][0], a, 127, strcmp);

	printf("%%!PS-Adobe-2.0\n%%%%DocumentPaperSizes: A4\n");
	printf("%%%%Pages: (atend) 1\n%%EndComments\n");
	printf("%%%%Page: 1 1\n %d %d %d %d rectclip\n", PAGECLIP);

	j = 0; k = 2;
	for (n = 0; n < a; ++n) {
		printf("%d %d moveto\n", 3*SIZE, 760 - j*(SIZE + 4));
		printf("/Helvetica findfont %d scalefont setfont\n", SIZE/2);
		printf("(%d. %s) show\n", n+1, fontarray[n]);
		printf("%d %d moveto\n", 11*SIZE, 760 - j*(SIZE + 4));
		printf("/%s findfont %d scalefont setfont\n", fontarray[n], SIZE-4);
		printf("(The Quick Brown Fox Jumps Over The Lazy Dog) show\n");
		++j;
		if (j == (PAPER_LENGTH/SIZE)) {
			j = 0;
			printf("showpage\n");
			printf("%%%%Page: %d %d\n %d %d %d %d rectclip\n", k, k, PAGECLIP);
			++k;
		}
	}
	printf("showpage\n");
	printf("%%%%Trailer\n%%%%Pages: %d %d\n", k-1, 1);
}    

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