include $(LIBCHARSET_SRCDIR)Makefile
MODULES := main malloc ustring error help licence version misc tree234
-MODULES += input in_afm keywords contents index biblio
+MODULES += input in_afm in_pf keywords contents index biblio
MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf
MODULES += winhelp psdata wcwidth
objtext(fontdesc, buf);
sprintf(buf, "/StemV %g\n", fi->stemv);
objtext(fontdesc, buf);
- objtext(fontdesc, ">>\n");
+ if (fi->fp) {
+ object *fontfile = new_object(&olist);
+ char buf[513];
+ size_t len;
+ rewind(fi->fp);
+ do {
+ len = fread(buf, 1, sizeof(buf)-1, fi->fp);
+ buf[len] = 0;
+ objstream(fontfile, buf);
+ } while (len == sizeof(buf)-1);
+ objtext(fontdesc, "/FontFile ");
+ objref(fontdesc, fontfile);
+ }
+ objtext(fontdesc, "\n>>\n");
}
objtext(font, "\n>>\n");
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");
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.
void read_afm_file(input *in);
/*
+ * in_pf.c
+ */
+void read_pfa_file(input *in);
+
+/*
* keywords.c
*/
struct keywordlist_Tag {
fi->nglyphs = 0;
fi->glyphs = NULL;
fi->widths = NULL;
+ fi->fp = NULL;
fi->kerns = newtree234(kern_cmp);
fi->fontbbox[0] = fi->fontbbox[1] = fi->fontbbox[2] = fi->fontbbox[3] = 0;
fi->capheight = fi->xheight = fi->ascent = fi->descent = 0;
--- /dev/null
+#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);
+}
+
+
if (strcmp(in->filenames[in->currindex] +
strlen(in->filenames[in->currindex]) - 4, ".afm") == 0)
read_afm_file(in);
+ else if (strcmp(in->filenames[in->currindex] +
+ strlen(in->filenames[in->currindex]) - 4, ".pfa") == 0)
+ read_pfa_file(in);
else
read_file(&hptr, in, idx, macros);
}
*/
const char *name;
/*
+ * The file containing this font, if any.
+ */
+ FILE *fp;
+ /*
* An array of pointers to the available glyph names, and their
* corresponding character widths. These two arrays have
* parallel indices.
if (done) return;
for (i = 0; i < (int)lenof(ps_std_fonts); i++) {
font_info *fi = snew(font_info);
+ fi->fp = NULL;
fi->name = ps_std_fonts[i].name;
fi->nglyphs = lenof(ps_std_glyphs) - 1;
fi->glyphs = ps_std_glyphs;