texlive[42743] Build/source/texk/dvipdfm-x/type1.c: dvipdfm-x:

commits+kakuto at tug.org commits+kakuto at tug.org
Sun Dec 18 23:04:29 CET 2016


Revision: 42743
          http://tug.org/svn/texlive?view=revision&revision=42743
Author:   kakuto
Date:     2016-12-18 23:04:28 +0100 (Sun, 18 Dec 2016)
Log Message:
-----------
dvipdfm-x: recover the original type1.c for [x]dvipdfmx

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/type1.c

Modified: trunk/Build/source/texk/dvipdfm-x/type1.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/type1.c	2016-12-18 15:05:55 UTC (rev 42742)
+++ trunk/Build/source/texk/dvipdfm-x/type1.c	2016-12-18 22:04:28 UTC (rev 42743)
@@ -324,6 +324,12 @@
       pdf_release_obj(tmp_array);
       return;
     }
+#if !defined(LIBDPX)
+    /* PLEASE FIX THIS
+     * It's wrong to use TFM width here... We should warn if TFM width
+     * and actual glyph width are different.
+     */
+#endif /* !LIBDPX */
     tfm_id = tfm_open(pdf_font_get_mapname(font), 0);
     for (code = firstchar; code <= lastchar; code++) {
       if (usedchars[code]) {
@@ -330,8 +336,24 @@
         double width;
         if (tfm_id < 0) /* tfm is not found */
           width = scaling * widths[cff_glyph_lookup(cffont, enc_vec[code])];
+#if defined(LIBDPX)
         else
-          width = 1000. * tfm_get_width(tfm_id, code);
+#else
+        else {
+          double diff;
+#endif /* LIBDPX */
+          width = 1000.0 * tfm_get_width(tfm_id, code);
+#if !defined(LIBDPX)
+          diff  = width -
+                    scaling * widths[cff_glyph_lookup(cffont, enc_vec[code])];
+          if (fabs(diff) > 1.0) {
+            WARN("Glyph width mismatch for TFM and font (%s)",
+                 pdf_font_get_mapname(font));
+            WARN("TFM: %g vs. Type1 font: %g",
+                 width, widths[cff_glyph_lookup(cffont, enc_vec[code])]);
+            }
+        }
+#endif /* !LIBDPX */
         pdf_add_array(tmp_array,
                       pdf_new_number(ROUND(width, 0.1)));
       } else {
@@ -356,7 +378,11 @@
 
 
 static int
+#if defined(LIBDPX)
 write_fontfile (pdf_font *font, cff_font *cffont)
+#else
+write_fontfile (pdf_font *font, cff_font *cffont, pdf_obj *pdfcharset)
+#endif /* LIBDPX */
 {
   pdf_obj   *descriptor;
   pdf_obj   *fontfile, *stream_dict;
@@ -467,7 +493,12 @@
                pdf_new_name("Subtype"),   pdf_new_name("Type1C"));
   pdf_add_stream (fontfile, (void *) stream_data_ptr,  offset);
   pdf_release_obj(fontfile);
-
+#if !defined(LIBDPX)
+  pdf_add_dict(descriptor,
+               pdf_new_name("CharSet"),
+               pdf_new_string(pdf_stream_dataptr(pdfcharset),
+                              pdf_stream_length(pdfcharset)));
+#endif /* !LIBDPX */
   RELEASE(stream_data_ptr);
 
   return offset;
@@ -478,6 +509,9 @@
 pdf_font_load_type1 (pdf_font *font)
 {
   pdf_obj      *fontdict;
+#if !defined(LIBDPX)
+  pdf_obj      *pdfcharset; /* Actually string object */
+#endif /* !LIBDPX */
   int           encoding_id;
   char         *usedchars, *ident;
   char         *fontname, *uniqueTag;
@@ -580,6 +614,9 @@
   /* Create CFF encoding, charset, sort glyphs */
 #define MAX_GLYPHS 1024
   GIDMap = NEW(MAX_GLYPHS, card16);
+#if !defined(LIBDPX)
+  pdfcharset = pdf_new_stream(0);
+#endif /* !LIBDPX */
   {
     int     prev, duplicate;
     int     gid;
@@ -652,7 +689,13 @@
         if (verbose > 2) {
           MESG("/%s", glyph);
         }
-
+#if !defined(LIBDPX)
+        /* CharSet is actually string object. */
+        {
+          pdf_add_stream(pdfcharset, "/", 1);
+          pdf_add_stream(pdfcharset, glyph, strlen(glyph));
+        }
+#endif /* !LIBDPX */
       }
     }
     if (cffont->encoding->num_supps > 0) {
@@ -776,10 +819,18 @@
 
   add_metrics(font, cffont, enc_vec, widths, num_glyphs);
 
+#if defined(LIBDPX)
   offset = write_fontfile(font, cffont);
+#else
+  offset = write_fontfile(font, cffont, pdfcharset);
+#endif /* LIBDPX */
   if (verbose > 1)
     MESG("[%u glyphs][%ld bytes]", num_glyphs, offset);
 
+#if !defined(LIBDPX)
+  pdf_release_obj(pdfcharset);
+#endif /* LIBDPX */
+
   cff_close(cffont);
 
   /* Cleanup */



More information about the tex-live-commits mailing list