Now that glyph indices are exposed to bk_pdf.c, move CMap generation there,
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 10 Feb 2007 13:35:52 +0000 (13:35 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 10 Feb 2007 13:35:52 +0000 (13:35 +0000)
since that seems closer to being where it belongs.

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

bk_pdf.c
in_sfnt.c
paper.h

index a880872..23408ee 100644 (file)
--- a/bk_pdf.c
+++ b/bk_pdf.c
@@ -197,7 +197,42 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
            object *cidfont = new_object(&olist);
            object *cmap = new_object(&olist);
            objtext(font, "/Subtype/Type0\n/Encoding ");
-           sfnt_cmap(fe, cmap);
+           objtext(cmap, "<</Type/CMap\n/CMapName/");
+           objtext(cmap, fe->name);
+           objtext(cmap, "\n/CIDSystemInfo<</Registry(Adobe)"
+                   "/Ordering(Identity)/Supplement 0>>\n");
+           objstream(cmap, "%!PS-Adobe-3.0 Resource-CMap\n"
+                     "%%DocumentNeededResources: procset CIDInit\n"
+                     "%%IncludeResource: procset CIDInit\n"
+                     "%%BeginResource: CMap ");
+           objstream(cmap, fe->name);
+           objstream(cmap, "\n%%Title (");
+           objstream(cmap, fe->name);
+           objstream(cmap, " Adobe Identity 0)\n%%Version: 1\n%%EndComments\n");
+           objstream(cmap, "/CIDInit/ProcSet findresource begin\n");
+           objstream(cmap, "12 dict begin begincmap\n");
+           objstream(cmap, "/CIDSystemInfo 3 dict dup begin\n"
+                     "/Registry(Adobe)def/Ordering(Identity)def"
+                     "/Supplement 0 def end def\n");
+           objstream(cmap, "/CMapName/");
+           objstream(cmap, fe->name);
+           objstream(cmap, " def/CMapType 0 def/WMode 0 def\n");
+           objstream(cmap, "1 begincodespacerange<00><FF>"
+                     "endcodespacerange\n");
+           for (i = 0; i < 256; i++) {
+               char buf[20];
+               if (fe->vector[i] == NOGLYPH)
+                   continue;
+               objstream(cmap, "1 begincidchar");
+               sprintf(buf, "<%02X>", i);
+               objstream(cmap, buf);
+               sprintf(buf, "%hu", sfnt_glyphtoindex(fe->font->info->fontfile,
+                                                     fe->vector[i]));
+               objstream(cmap, buf);
+               objstream(cmap, " endcidchar\n");
+           }
+           objstream(cmap, "endcmap CMapName currentdict /CMap "
+                     "defineresource pop end end\n%%EndResource\n%%EOF\n");
            objref(font, cmap);
            objtext(font, "\n/DescendantFonts[");
            objref(font, cidfont);
@@ -537,7 +572,7 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
            zbuf = snewn(zlen, char);
            memcpy(zbuf, o->stream.text, zlen);
            sprintf(text, "/Length %d\n>>\n", zlen);
-#else      
+#else
            zcontext = deflate_compress_new(DEFLATE_TYPE_ZLIB);
            deflate_compress_data(zcontext, o->stream.text, o->stream.pos,
                                  DEFLATE_END_OF_DATA, &zbuf, &zlen);
index 9718425..b33a2a1 100644 (file)
--- a/in_sfnt.c
+++ b/in_sfnt.c
@@ -806,46 +806,6 @@ void sfnt_writeps(font_info const *fi, FILE *ofp) {
     fprintf(ofp, "end /%s exch definefont\n", fi->name);
 }
 
-void sfnt_cmap(font_encoding *fe, object *cmap) {
-    unsigned i;
-
-    objtext(cmap, "<</Type/CMap\n/CMapName/");
-    objtext(cmap, fe->name);
-    objtext(cmap, "\n/CIDSystemInfo<</Registry(Adobe)/Ordering(Identity)"
-           "/Supplement 0>>\n");
-    objstream(cmap, "%!PS-Adobe-3.0 Resource-CMap\n"
-             "%%DocumentNeededResources: procset CIDInit\n"
-             "%%IncludeResource: procset CIDInit\n"
-             "%%BeginResource: CMap ");
-    objstream(cmap, fe->name);
-    objstream(cmap, "\n%%Title (");
-    objstream(cmap, fe->name);
-    objstream(cmap, " Adobe Identity 0)\n%%Version: 1\n%%EndComments\n");
-    objstream(cmap, "/CIDInit/ProcSet findresource begin\n");
-    objstream(cmap, "12 dict begin begincmap\n");
-    objstream(cmap, "/CIDSystemInfo 3 dict dup begin\n"
-             "/Registry(Adobe)def/Ordering(Identity)def/Supplement 0 def "
-             "end def\n");
-    objstream(cmap, "/CMapName/");
-    objstream(cmap, fe->name);
-    objstream(cmap, " def/CMapType 0 def/WMode 0 def\n");
-    objstream(cmap, "1 begincodespacerange<00><FF>endcodespacerange\n");
-    for (i = 0; i < 256; i++) {
-       char buf[20];
-       if (fe->vector[i] == NOGLYPH)
-           continue;
-       objstream(cmap, "1 begincidchar");
-       sprintf(buf, "<%02X>", i);
-       objstream(cmap, buf);
-       sprintf(buf, "%hu", sfnt_glyphtoindex(fe->font->info->fontfile,
-                                             fe->vector[i]));
-       objstream(cmap, buf);
-       objstream(cmap, " endcidchar\n");
-    }
-    objstream(cmap, "endcmap CMapName currentdict /CMap defineresource pop "
-             "end end\n%%EndResource\n%%EOF\n");
-}
-
 void sfnt_data(font_info *fi, char **bufp, size_t *lenp) {
     sfnt *sf = fi->fontfile;
     *bufp = sf->data;
diff --git a/paper.h b/paper.h
index d0c0139..652fa7e 100644 (file)
--- a/paper.h
+++ b/paper.h
@@ -423,7 +423,6 @@ 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);
 
 #endif