summaryrefslogtreecommitdiff
path: root/fonts/hershey/font.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /fonts/hershey/font.c
Initial commit
Diffstat (limited to 'fonts/hershey/font.c')
-rw-r--r--fonts/hershey/font.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/fonts/hershey/font.c b/fonts/hershey/font.c
new file mode 100644
index 0000000000..c6af8fed28
--- /dev/null
+++ b/fonts/hershey/font.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+
+static char copyright[] = "Copyright (C) Ken Yap 1988";
+
+static long position[10000];
+#define sizeoftab (sizeof(position)/sizeof(position[0]))
+
+scanfont(f)
+ FILE *f;
+{
+ register int i, index;
+ register long pos;
+ char line[512];
+ char sindex[6];
+
+ for (i = 0; i < sizeoftab; ++i)
+ position[i] = -2;
+ sindex[5] = '\0';
+ pos = 0L;
+ while (fgets(line, sizeof(line), f) != NULL)
+ {
+ (void)strncpy(sindex, line, 5);
+ index = atoi(sindex);
+ if (index < 0 || index >= sizeoftab)
+ {
+ (void)fprintf(stderr, "Bad char index %s\n", sindex);
+ continue;
+ }
+ position[index] = pos;
+ pos = ftell(f);
+ }
+ (void)fseek(f, 0L, 0);
+}
+
+int getline(f, index, buf, buflen)
+ FILE *f;
+ int index;
+ char *buf;
+ int buflen;
+{
+ register long pos;
+
+ if (index < 0 || index >= sizeoftab)
+ return (0);
+ if ((pos = position[index]) < 0)
+ return (0);
+ if (fseek(f, pos, 0) < 0)
+ return (0);
+ if (fgets(buf, buflen, f) == NULL)
+ return (0);
+ return (1);
+}