diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2006-05-14 13:42:48 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2006-05-14 13:42:48 +0000 |
| commit | e06921ba9541759101336126a6af96ab66b9ee2d (patch) | |
| tree | 96ec2e47e9f592d08ea7af56893873e5c4704bbf /in_pf.c | |
| parent | 9f368a32d754b2827a38f51aa6191aa625ce6a10 (diff) | |
| download | halibut-e06921ba9541759101336126a6af96ab66b9ee2d.zip halibut-e06921ba9541759101336126a6af96ab66b9ee2d.tar.gz halibut-e06921ba9541759101336126a6af96ab66b9ee2d.tar.bz2 halibut-e06921ba9541759101336126a6af96ab66b9ee2d.tar.xz | |
Fairly ropey font-embedding support. In particular, the PDF output is
technically incorrect, though it works perfectly well with xpdf. To do
it properly requires actually parsing the unencrypted part of a Type 1
font, which will be a bit tedious in C.
[originally from svn r6685]
Diffstat (limited to 'in_pf.c')
| -rw-r--r-- | in_pf.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -0,0 +1,34 @@ +#include <stdio.h> +#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); +} + + |