summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-06-25 14:08:05 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-06-25 14:08:05 +0000
commitcc6aa42af9e93d8f6ccc61baa0c90370e92f7fa9 (patch)
tree516ac1a9dda0ede28d87720bc0275a45789a16be /Build/source
parented2b54f5b66c81f8607ddb231b0e164e3b6cf235 (diff)
dvipdfm-x: (From S. Hirata) Modify to make PDF/A generation a bit easier.
git-svn-id: svn://tug.org/texlive/trunk@41537 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog7
-rw-r--r--Build/source/texk/dvipdfm-x/cidtype2.c9
-rw-r--r--Build/source/texk/dvipdfm-x/pdfobj.c12
-rw-r--r--Build/source/texk/dvipdfm-x/type1.c35
-rw-r--r--Build/source/texk/dvipdfm-x/type1c.c24
5 files changed, 73 insertions, 14 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 4541438c63e..62288f6dfc5 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-25 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
+
+ Modify to make PDF/A generation a bit easier.
+ * pdfobj.c: Do not compress XMP Metadata.
+ * cidtype2.c, type1.c, type1c.c: Always write CIDSet for CIDType2 and
+ CharSet for Type1 font. Check consistency of glyph width.
+
2016-06-19 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
* dvipdfmx.c: Disable overriding "D" option setting from
diff --git a/Build/source/texk/dvipdfm-x/cidtype2.c b/Build/source/texk/dvipdfm-x/cidtype2.c
index a7cad383a74..63f7e045be0 100644
--- a/Build/source/texk/dvipdfm-x/cidtype2.c
+++ b/Build/source/texk/dvipdfm-x/cidtype2.c
@@ -915,8 +915,15 @@ CIDFont_type2_dofont (CIDFont *font)
/*
* CIDToGIDMap
+ * Adobe's PDF Reference had been describing it as "optional" and
+ * default value as "Identity". However, ISO 32000-1 requires it
+ * for Type 2 CIDFonts with embedded font programs.
*/
- if (cidtogidmap) {
+ if (!cidtogidmap) {
+ pdf_add_dict(font->fontdict,
+ pdf_new_name("CIDToGIDMap"),
+ pdf_new_name("Identity"));
+ } else {
pdf_obj *c2gmstream;
c2gmstream = pdf_new_stream(STREAM_COMPRESS);
diff --git a/Build/source/texk/dvipdfm-x/pdfobj.c b/Build/source/texk/dvipdfm-x/pdfobj.c
index 26ce1e0cb65..3dadf0a140d 100644
--- a/Build/source/texk/dvipdfm-x/pdfobj.c
+++ b/Build/source/texk/dvipdfm-x/pdfobj.c
@@ -1937,10 +1937,14 @@ write_stream (pdf_stream *stream, FILE *file)
memcpy(filtered, stream->stream, stream->stream_length);
filtered_length = stream->stream_length;
-#if 0
- if (stream->stream_length < 10)
- stream->_flags &= ^STREAM_COMPRESS;
-#endif
+ /* PDF/A requires Metadata to be not filtered. */
+ {
+ pdf_obj *type;
+ type = pdf_lookup_dict(stream->dict, "Type");
+ if (type && !strcmp("Metadata", pdf_name_value(type))) {
+ stream->_flags &= ~STREAM_COMPRESS;
+ }
+ }
#ifdef HAVE_ZLIB
/* Apply compression filter if requested */
diff --git a/Build/source/texk/dvipdfm-x/type1.c b/Build/source/texk/dvipdfm-x/type1.c
index b74030c986f..008c97d4ee1 100644
--- a/Build/source/texk/dvipdfm-x/type1.c
+++ b/Build/source/texk/dvipdfm-x/type1.c
@@ -324,14 +324,28 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, i
pdf_release_obj(tmp_array);
return;
}
+ /* PLEASE FIX THIS
+ * It's wrong to use TFM width here... We should warn if TFM width
+ * and actual glyph width are different.
+ */
tfm_id = tfm_open(pdf_font_get_mapname(font), 0);
for (code = firstchar; code <= lastchar; code++) {
if (usedchars[code]) {
double width;
if (tfm_id < 0) /* tfm is not found */
width = scaling * widths[cff_glyph_lookup(cffont, enc_vec[code])];
- else
+ else {
+ double diff;
width = 1000. * tfm_get_width(tfm_id, code);
+ diff = width -
+ scaling * widths[cff_glyph_lookup(cffont, enc_vec[code])];
+ if (fabs(diff) > 1.) {
+ 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])]);
+ }
+ }
pdf_add_array(tmp_array,
pdf_new_number(ROUND(width, 0.1)));
} else {
@@ -356,7 +370,7 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, i
static int
-write_fontfile (pdf_font *font, cff_font *cffont)
+write_fontfile (pdf_font *font, cff_font *cffont, pdf_obj *pdfcharset)
{
pdf_obj *descriptor;
pdf_obj *fontfile, *stream_dict;
@@ -467,7 +481,10 @@ write_fontfile (pdf_font *font, cff_font *cffont)
pdf_new_name("Subtype"), pdf_new_name("Type1C"));
pdf_add_stream (fontfile, (void *) stream_data_ptr, offset);
pdf_release_obj(fontfile);
-
+ pdf_add_dict(descriptor,
+ pdf_new_name("CharSet"),
+ pdf_new_string(pdf_stream_dataptr(pdfcharset),
+ pdf_stream_length(pdfcharset)));
RELEASE(stream_data_ptr);
return offset;
@@ -478,6 +495,7 @@ int
pdf_font_load_type1 (pdf_font *font)
{
pdf_obj *fontdict;
+ pdf_obj *pdfcharset; /* Actually string object */
int encoding_id;
char *usedchars, *ident;
char *fontname, *uniqueTag;
@@ -580,6 +598,7 @@ pdf_font_load_type1 (pdf_font *font)
/* Create CFF encoding, charset, sort glyphs */
#define MAX_GLYPHS 1024
GIDMap = NEW(MAX_GLYPHS, card16);
+ pdfcharset = pdf_new_stream(0);
{
int prev, duplicate;
int gid;
@@ -652,7 +671,11 @@ pdf_font_load_type1 (pdf_font *font)
if (verbose > 2) {
MESG("/%s", glyph);
}
-
+ /* CharSet is actually string object. */
+ {
+ pdf_add_stream(pdfcharset, "/", 1);
+ pdf_add_stream(pdfcharset, glyph, strlen(glyph));
+ }
}
}
if (cffont->encoding->num_supps > 0) {
@@ -776,10 +799,12 @@ pdf_font_load_type1 (pdf_font *font)
add_metrics(font, cffont, enc_vec, widths, num_glyphs);
- offset = write_fontfile(font, cffont);
+ offset = write_fontfile(font, cffont, pdfcharset);
if (verbose > 1)
MESG("[%u glyphs][%ld bytes]", num_glyphs, offset);
+ pdf_release_obj(pdfcharset);
+
cff_close(cffont);
/* Cleanup */
diff --git a/Build/source/texk/dvipdfm-x/type1c.c b/Build/source/texk/dvipdfm-x/type1c.c
index 5035009d90f..777ca53929b 100644
--- a/Build/source/texk/dvipdfm-x/type1c.c
+++ b/Build/source/texk/dvipdfm-x/type1c.c
@@ -201,10 +201,18 @@ add_SimpleMetrics (pdf_font *font, cff_font *cffont,
double width;
if (tfm_id < 0) /* tfm is not found */
width = scaling * widths[code];
- else
+ else {
+ double diff;
width = 1000. * tfm_get_width(tfm_id, code);
+ diff = width - scaling * widths[code];
+ if (fabs(diff) > 1.) {
+ WARN("Glyph width mismatch for TFM and font (%s)",
+ pdf_font_get_mapname(font));
+ WARN("TFM: %g vs. CFF font: %g", width, widths[code]);
+ }
pdf_add_array(tmp_array,
pdf_new_number(ROUND(width, 0.1)));
+ }
} else {
pdf_add_array(tmp_array, pdf_new_number(0.0));
}
@@ -229,6 +237,7 @@ int
pdf_font_load_type1c (pdf_font *font)
{
pdf_obj *fontdict, *descriptor;
+ pdf_obj *pdfcharset; /* Actually string object */
char *usedchars;
char *fontname, *uniqueTag, *ident, *fullname;
FILE *fp = NULL;
@@ -449,6 +458,7 @@ pdf_font_load_type1c (pdf_font *font)
* Subset font
*/
num_glyphs = 1;
+ pdfcharset = pdf_new_stream(0);
for (code = 0; code < 256; code++) {
card16 gid, j;
s_SID sid_orig, sid;
@@ -498,6 +508,9 @@ pdf_font_load_type1c (pdf_font *font)
usedchars[code] = 0; /* Set unused for writing correct encoding */
continue;
}
+ pdf_add_stream(pdfcharset, "/", 1);
+ pdf_add_stream(pdfcharset, enc_vec[code], strlen(enc_vec[code]));
+
if (verbose > 2) {
MESG("/%s", enc_vec[code]);
}
@@ -717,10 +730,13 @@ pdf_font_load_type1c (pdf_font *font)
}
/*
- * CharSet might be recommended for subsetted font, but it is meaningful
- * only for Type 1 font...
+ * CharSet
*/
-
+ pdf_add_dict(descriptor,
+ pdf_new_name("CharSet"),
+ pdf_new_string(pdf_stream_dataptr(pdfcharset),
+ pdf_stream_length(pdfcharset)));
+ pdf_release_obj(pdfcharset);
/*
* Write PDF FontFile data.
*/