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 /bk_ps.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 'bk_ps.c')
| -rw-r--r-- | bk_ps.c | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -56,8 +56,13 @@ void ps_backend(paragraph *sourceform, keywordlist *keywords, fprintf(fp, "%%%%DocumentNeededResources:\n"); for (fe = doc->fonts->head; fe; fe = fe->next) /* XXX This may request the same font multiple times. */ - fprintf(fp, "%%%%+ font %s\n", fe->font->info->name); + if (!fe->font->info->fp) + fprintf(fp, "%%%%+ font %s\n", fe->font->info->name); fprintf(fp, "%%%%DocumentSuppliedResources: procset Halibut 0 0\n"); + for (fe = doc->fonts->head; fe; fe = fe->next) + /* XXX This may request the same font multiple times. */ + if (fe->font->info->fp) + fprintf(fp, "%%%%+ font %s\n", fe->font->info->name); fprintf(fp, "%%%%EndComments\n"); fprintf(fp, "%%%%BeginProlog\n"); @@ -94,9 +99,23 @@ void ps_backend(paragraph *sourceform, keywordlist *keywords, if (p->type == para_VersionID) ps_comment(fp, "% ", p->words); - for (fe = doc->fonts->head; fe; fe = fe->next) + for (fe = doc->fonts->head; fe; fe = fe->next) { /* XXX This may request the same font multiple times. */ - fprintf(fp, "%%%%IncludeResource: font %s\n", fe->font->info->name); + if (fe->font->info->fp) { + char buf[512]; + size_t len; + fprintf(fp, "%%%%BeginResource: font %s\n", fe->font->info->name); + rewind(fe->font->info->fp); + do { + len = fread(buf, 1, sizeof(buf), fe->font->info->fp); + fwrite(buf, 1, len, fp); + } while (len == sizeof(buf)); + fprintf(fp, "%%%%EndResource\n"); + } else { + fprintf(fp, "%%%%IncludeResource: font %s\n", + fe->font->info->name); + } + } /* * Re-encode the fonts. |