Generate a "W" array for CIDFonts, since acroread seems to do very silly
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 10 Feb 2007 12:33:56 +0000 (12:33 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 10 Feb 2007 12:33:56 +0000 (12:33 +0000)
things without one.

git-svn-id: svn://svn.tartarus.org/sgt/halibut@7261 cda61777-01e9-0310-a592-d414129be87e

bk_pdf.c
in_sfnt.c
paper.h

index d75244d..a880872 100644 (file)
--- a/bk_pdf.c
+++ b/bk_pdf.c
@@ -209,7 +209,16 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
                    "/Ordering(Identity)/Supplement 0>>\n");
            objtext(cidfont, "/FontDescriptor ");
            objref(cidfont, fontdesc);
-           objtext(cidfont, ">>\n");
+           objtext(cidfont, "\n/W[0[");
+           for (i = 0; i < sfnt_nglyphs(fe->font->info->fontfile); i++) {
+               char buf[20];
+               double width;
+               width = find_width(fe->font,
+                              sfnt_indextoglyph(fe->font->info->fontfile, i));
+               sprintf(buf, "%g ", 1000.0 * width / FUNITS_PER_PT);
+               objtext(cidfont, buf);
+           }
+           objtext(cidfont, "]]>>\n");
        } else {
            objtext(font, "/Subtype /Type1\n");
            objtext(font, "\n/Encoding <<\n/Type /Encoding\n/Differences [");
index 9e21bf2..9718425 100644 (file)
--- a/in_sfnt.c
+++ b/in_sfnt.c
@@ -349,7 +349,6 @@ typedef struct {
     unsigned short index;
 } glyphmap;
 
-typedef struct sfnt_Tag sfnt;
 struct sfnt_Tag {
     void *data;
     size_t len;
@@ -497,11 +496,15 @@ static void sfnt_mapglyphs(font_info *fi) {
          glyphsbyname_cmp);
 }
 
-static glyph sfnt_indextoglyph(sfnt *sf, unsigned short idx) {
+glyph sfnt_indextoglyph(sfnt *sf, unsigned idx) {
     return sf->glyphsbyindex[idx];
 }
 
-static unsigned short sfnt_glyphtoindex(sfnt *sf, glyph g) {
+unsigned sfnt_nglyphs(sfnt *sf) {
+    return sf->nglyphs;
+}
+
+unsigned sfnt_glyphtoindex(sfnt *sf, glyph g) {
     cmp_glyphsbyindex = sf->glyphsbyindex;
     return *(unsigned short *)bsearch(&g, sf->glyphsbyname, sf->nglyphs,
                                      sizeof(*sf->glyphsbyname),
diff --git a/paper.h b/paper.h
index 3f20fc2..d0c0139 100644 (file)
--- a/paper.h
+++ b/paper.h
@@ -418,6 +418,10 @@ void pf_writeps(font_info const *fi, FILE *ofp);
 /*
  * Backend functions exported by in_sfnt.c
  */
+typedef struct sfnt_Tag sfnt;
+glyph sfnt_indextoglyph(sfnt *sf, unsigned idx);
+unsigned sfnt_glyphtoindex(sfnt *sf, glyph g);
+unsigned sfnt_nglyphs(sfnt *sf);
 void sfnt_writeps(font_info const *fi, FILE *ofp);
 void sfnt_cmap(font_encoding *fe, object *);
 void sfnt_data(font_info *fi, char **bufp, size_t *lenp);