I haven't found any browsers that do anything disgusting with
[sgt/halibut] / bk_pdf.c
index 319e8fb..99eb933 100644 (file)
--- a/bk_pdf.c
+++ b/bk_pdf.c
@@ -159,14 +159,14 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
 
        for (i = 0; i < 256; i++) {
            char buf[20];
-           if (!fe->vector[i])
+           if (fe->vector[i] == NOGLYPH)
                continue;
            if (i != prev + 1) {
                sprintf(buf, "\n%d", i);
                objtext(font, buf);
            }
            objtext(font, i % 8 ? "/" : "\n/");
-           objtext(font, fe->vector[i]);
+           objtext(font, glyph_extern(fe->vector[i]));
            prev = i;
        }
 
@@ -190,7 +190,7 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
            font_info const *fi = fe->font->info;
            int flags;
            for (i = 0; i < 256; i++)
-               if (fe->indices[i] >= 0) {
+               if (fe->vector[i] != NOGLYPH) {
                    if (firstchar < 0) firstchar = i;
                    lastchar = i;
                }
@@ -202,10 +202,10 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
            objtext(widths, "[\n");
            for (i = firstchar; i <= lastchar; i++) {
                double width;
-               if (fe->indices[i] < 0)
+               if (fe->vector[i] == NOGLYPH)
                    width = 0.0;
                else
-                   width = fi->widths[fe->indices[i]];
+                   width = find_width(fe->font, fe->vector[i]);
                sprintf(buf, "%g\n", 1000.0 * width / FUNITS_PER_PT);
                objtext(widths, buf);
            }
@@ -236,7 +236,7 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
            objtext(fontdesc, buf);
            sprintf(buf, "/StemV %g\n", fi->stemv);
            objtext(fontdesc, buf);
-           if (fi->fp) {
+           if (fi->fontfile) {
                object *fontfile = new_object(&olist);
                size_t len;
                char *ffbuf;
@@ -487,18 +487,20 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
        rdaddsc(&rs, text);
 
        if (o->stream.text) {
-           char buf[100];
-           sprintf(buf, "stream%06d", o->number);
-           fp = fopen(buf, "wb");
-           fwrite(o->stream.text, 1, o->stream.pos, fp);
-           fclose(fp);
+           if (!o->main.text)
+               rdaddsc(&o->main, "<<\n");
+#ifdef PDF_NOCOMPRESS
+           zlen = o->stream.pos;
+           zbuf = snewn(zlen, char);
+           memcpy(zbuf, o->stream.text, zlen);
+           sprintf(text, "/Length %d\n>>\n", zlen);
+#else      
            zcontext = deflate_compress_new(DEFLATE_TYPE_ZLIB);
            deflate_compress_data(zcontext, o->stream.text, o->stream.pos,
                                  DEFLATE_END_OF_DATA, &zbuf, &zlen);
            deflate_compress_free(zcontext);
-           if (!o->main.text)
-               rdaddsc(&o->main, "<<\n");
            sprintf(text, "/Filter/FlateDecode\n/Length %d\n>>\n", zlen);
+#endif
            rdaddsc(&o->main, text);
        }