| 1 | #include <stdio.h> |
| 2 | #include "halibut.h" |
| 3 | #include "paper.h" |
| 4 | |
| 5 | void read_pfa_file(input *in) { |
| 6 | char buf[512], *p; |
| 7 | size_t len; |
| 8 | char *fontname; |
| 9 | font_info *fi; |
| 10 | |
| 11 | len = fread(buf, 1, sizeof(buf) - 1, in->currfp); |
| 12 | buf[len] = 0; |
| 13 | if (strncmp(buf, "%!FontType1-", 12) && |
| 14 | strncmp(buf, "%!PS-AdobeFont-", 15)) |
| 15 | return; |
| 16 | p = buf; |
| 17 | p += strcspn(p, ":") + 1; |
| 18 | p += strspn(p, " \t"); |
| 19 | len = strcspn(p, " \t"); |
| 20 | fontname = snewn(len + 1, char); |
| 21 | memcpy(fontname, p, len); |
| 22 | fontname[len] = 0; |
| 23 | for (fi = all_fonts; fi; fi = fi->next) { |
| 24 | if (strcmp(fi->name, fontname) == 0) { |
| 25 | fi->fp = in->currfp; |
| 26 | sfree(fontname); |
| 27 | return; |
| 28 | } |
| 29 | } |
| 30 | fclose(in->currfp); |
| 31 | sfree(fontname); |
| 32 | } |
| 33 | |
| 34 | |