X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/255b7ff3a0fcea3fb9f041c4ce371ef8ca66e5fa..44407fea05657f91da34fd83428b67e7100ab62b:/in_pf.c diff --git a/in_pf.c b/in_pf.c new file mode 100644 index 0000000..50e663e --- /dev/null +++ b/in_pf.c @@ -0,0 +1,34 @@ +#include +#include "halibut.h" +#include "paper.h" + +void read_pfa_file(input *in) { + char buf[512], *p; + size_t len; + char *fontname; + font_info *fi; + + len = fread(buf, 1, sizeof(buf) - 1, in->currfp); + buf[len] = 0; + if (strncmp(buf, "%!FontType1-", 12) && + strncmp(buf, "%!PS-AdobeFont-", 15)) + return; + p = buf; + p += strcspn(p, ":") + 1; + p += strspn(p, " \t"); + len = strcspn(p, " \t"); + fontname = snewn(len + 1, char); + memcpy(fontname, p, len); + fontname[len] = 0; + for (fi = all_fonts; fi; fi = fi->next) { + if (strcmp(fi->name, fontname) == 0) { + fi->fp = in->currfp; + sfree(fontname); + return; + } + } + fclose(in->currfp); + sfree(fontname); +} + +