summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Melichev <igor.melichev@artifex.com>2003-03-21 19:14:24 +0000
committerIgor Melichev <igor.melichev@artifex.com>2003-03-21 19:14:24 +0000
commit3984cb3947a57ea88bd0fc0cc11e9a85a71bb238 (patch)
tree19a753e467e1002daeb5bba6fb55e71025fc35aa
parent65ad7798663157e3353ee2d345124941509a572d (diff)
pdfwrite : Fixing the bug 653140 "use NeverEmbed to restrict CIDFont embedding"
DETAILS : The important change is setting pfont->font_name for CID fonts. Before now it contained empty string. Other changes are minor and only provide a data transfer. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@3731 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/doc/Ps2pdf.htm10
-rw-r--r--gs/src/bfont.h2
-rw-r--r--gs/src/gdevpdtb.c6
-rw-r--r--gs/src/gdevpdtb.h2
-rw-r--r--gs/src/gdevpdtd.c2
-rw-r--r--gs/src/gdevpdtf.c15
-rw-r--r--gs/src/gdevpdtf.h4
-rw-r--r--gs/src/zbfont.c6
-rw-r--r--gs/src/zfcid0.c5
-rw-r--r--gs/src/zfcid1.c5
10 files changed, 42 insertions, 15 deletions
diff --git a/gs/doc/Ps2pdf.htm b/gs/doc/Ps2pdf.htm
index 94de9ed8e..db88ed760 100644
--- a/gs/doc/Ps2pdf.htm
+++ b/gs/doc/Ps2pdf.htm
@@ -282,7 +282,7 @@ containing '=' mean that the value of the parameter is the same as in the
<tr valign=top><td><b><tt>MonoImageDownsampleType</tt></b><td><td><td><td>/Subsample<td><td>/Average<td><td>/Bicubic<td><td>/Bicubic<td><td>/Bicubic
<tr valign=top><td><b><tt>MonoImageFilter</tt></b><td><td><td><td>/CCITTFaxEncode<td><td>=<td><td>=<td><td>=<td><td>=
<tr valign=top><td><b><tt>MonoImageResolution</tt></b><td><td><td><td>300<td><td>300<td><td>300<td><td>1200<td><td>1200
-<tr valign=top><td><b><tt>NeverEmbed</tt></b><td><td><td><td><a href="#note_11">(note 11)</a><td><td><a href="#note_11">(note 11)</a><td><td><a href="#note_11">(note 11)</a><td><td>[]<td><td>[]
+<tr valign=top><td><b><tt>NeverEmbed</tt></b><td><td><td><td><a href="#note_11">(note 11)</a><a href="#note_12">(note 12)</a><td><td><a href="#note_11">(note 11)</a><a href="#note_12">(note 12)</a><td><td><a href="#note_11">(note 11)</a><a href="#note_12">(note 12)</a><td><td>[]<a href="#note_12">(note 12)</a><td><td>[]<a href="#note_12">(note 12)</a>
<tr valign=top><td><b><tt>OffOptimizations</tt></b><td><td><td><td>0<td><td>=<td><td>=<td><td>=<td><td>=
<tr valign=top><td><b><tt>OPM</tt></b><td><td><td><td>1<td><td>=<td><td>=<td><td>=<td><td>=
<tr valign=top><td><b><tt>Optimize</tt></b><td><td><a href="#note_0">(0</a>,<a href="#note_5">5)</a><td><td>false<td><td>true<td><td>true<td><td>true<td><td>true
@@ -385,6 +385,14 @@ The screen and ebook ACS image parameter dictionary is
The default, screen, and ebook settings never embed the 14 standard fonts
(Courier, Helvetica, and Times families, Symbol, and ZapfDingbats).
+<p>
+<a name="note_12">(note 12)</a>
+<b><tt>NeverEnbed</tt></b> can include CID font names.
+If a CID font is substituted in <b><tt>lib/cidfmap</tt></b>,
+the substitute font name is used when the CID font is embedded,
+and the original CID font name is used when it is not embedded.
+<b><tt>NeverEnbed</tt></b> should always specify the original CID font name.
+
<hr>
<h2><a name="Limitations"></a>Limitations</h2>
diff --git a/gs/src/bfont.h b/gs/src/bfont.h
index 00d131805..3893c13db 100644
--- a/gs/src/bfont.h
+++ b/gs/src/bfont.h
@@ -75,6 +75,8 @@ int build_gs_sub_font(i_ctx_t *, const ref *, gs_font **,
font_type, gs_memory_type_ptr_t,
const build_proc_refs *, const ref *, ref *);
int define_gs_font(gs_font *);
+void get_font_name(ref * pfname, const ref * op);
+void copy_font_name(gs_font_name * pfstr, const ref * pfname);
gs_glyph zfont_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t ignored);
gs_char gs_font_map_glyph_to_unicode(gs_font *font, gs_glyph glyph);
const ref *zfont_get_to_unicode_map(gs_font_dir *dir);
diff --git a/gs/src/gdevpdtb.c b/gs/src/gdevpdtb.c
index 73393efb5..5728ea585 100644
--- a/gs/src/gdevpdtb.c
+++ b/gs/src/gdevpdtb.c
@@ -28,6 +28,7 @@
#include "gdevpsf.h"
#include "gdevpdfx.h"
#include "gdevpdtb.h"
+#include "gdevpdtf.h"
/*
* Adobe's Distiller Parameters documentation for Acrobat Distiller 5
@@ -161,7 +162,7 @@ pdf_end_fontfile(gx_device_pdf *pdev, pdf_data_writer_t *pdw)
*/
int
pdf_base_font_alloc(gx_device_pdf *pdev, pdf_base_font_t **ppbfont,
- gs_font_base *font, bool is_standard)
+ gs_font_base *font, bool is_standard, bool orig_name)
{
gs_memory_t *mem = pdev->pdf_memory;
gs_font *copied;
@@ -169,8 +170,7 @@ pdf_base_font_alloc(gx_device_pdf *pdev, pdf_base_font_t **ppbfont,
pdf_base_font_t *pbfont =
gs_alloc_struct(mem, pdf_base_font_t,
&st_pdf_base_font, "pdf_base_font_alloc");
- const gs_font_name *pfname =
- (font->font_name.size != 0 ? &font->font_name : &font->key_name);
+ const gs_font_name *pfname = pdf_choose_font_name((gs_font *)font, orig_name);
gs_const_string font_name;
char fnbuf[3 + sizeof(long) / 3 + 1]; /* .F#######\0 */
int code;
diff --git a/gs/src/gdevpdtb.h b/gs/src/gdevpdtb.h
index 940b8cc5c..b6d89023b 100644
--- a/gs/src/gdevpdtb.h
+++ b/gs/src/gdevpdtb.h
@@ -74,7 +74,7 @@ typedef struct pdf_base_font_s pdf_base_font_t;
* a complete one, and adding glyphs or Encoding entries is not allowed.
*/
int pdf_base_font_alloc(gx_device_pdf *pdev, pdf_base_font_t **ppbfont,
- gs_font_base *font, bool complete);
+ gs_font_base *font, bool complete, bool orig_name);
/*
* Return a reference to the name of a base font. This name is guaranteed
diff --git a/gs/src/gdevpdtd.c b/gs/src/gdevpdtd.c
index 28a1aa080..e5ca724a3 100644
--- a/gs/src/gdevpdtd.c
+++ b/gs/src/gdevpdtd.c
@@ -216,7 +216,7 @@ pdf_font_descriptor_alloc(gx_device_pdf *pdev, pdf_font_descriptor_t **ppfd,
{
pdf_font_descriptor_t *pfd;
pdf_base_font_t *pbfont;
- int code = pdf_base_font_alloc(pdev, &pbfont, font, false);
+ int code = pdf_base_font_alloc(pdev, &pbfont, font, false, !embed);
if (code < 0)
return code;
diff --git a/gs/src/gdevpdtf.c b/gs/src/gdevpdtf.c
index 21a8cb36a..e04aaa990 100644
--- a/gs/src/gdevpdtf.c
+++ b/gs/src/gdevpdtf.c
@@ -491,12 +491,21 @@ embed_as_standard(gx_device_pdf *pdev, gs_font *font, int index,
return (find_std_appearance(pdev, (gs_font_base *)font, -1,
glyphs, num_glyphs) == index);
}
+/*
+ * Choose a name for embedded font.
+ */
+const gs_font_name *pdf_choose_font_name(gs_font *font, bool orig_name)
+{
+ return orig_name ? (font->key_name.size != 0 ? &font->key_name : &font->font_name)
+ : (font->font_name.size != 0 ? &font->font_name : &font->key_name);
+}
pdf_font_embed_t
pdf_font_embed_status(gx_device_pdf *pdev, gs_font *font, int *pindex,
gs_glyph *glyphs, int num_glyphs)
{
- const byte *chars = font->font_name.chars;
- uint size = font->font_name.size;
+ const gs_font_name *fn = pdf_choose_font_name(font, true);
+ const byte *chars = fn->chars;
+ uint size = fn->size;
int index = pdf_find_standard_font_name(chars, size);
bool embed_as_standard_called = false, do_embed_as_standard;
@@ -653,7 +662,7 @@ pdf_font_std_alloc(gx_device_pdf *pdev, pdf_font_resource_t **ppfres,
pdf_standard_font_t *psf = &pdf_standard_fonts(pdev)[index];
if (code < 0 ||
- (code = pdf_base_font_alloc(pdev, &pdfont->base_font, pfont, true)) < 0
+ (code = pdf_base_font_alloc(pdev, &pdfont->base_font, pfont, true, true)) < 0
)
return code;
pdfont->BaseFont.data = (byte *)psfi->fname; /* break const */
diff --git a/gs/src/gdevpdtf.h b/gs/src/gdevpdtf.h
index 16edf9082..a2e71abfc 100644
--- a/gs/src/gdevpdtf.h
+++ b/gs/src/gdevpdtf.h
@@ -341,6 +341,10 @@ int pdf_compute_BaseFont(gx_device_pdf *pdev, pdf_font_resource_t *pdfont);
*/
int pdf_close_text_document(gx_device_pdf *pdev); /* in gdevpdtw.c */
+/*
+ * Choose a name for embedded font.
+ */
+const gs_font_name *pdf_choose_font_name(gs_font *font, bool orig_name);
/* ---------------- CMap resources ---------------- */
/*
diff --git a/gs/src/zbfont.c b/gs/src/zbfont.c
index e1e7fd302..cf8ffc462 100644
--- a/gs/src/zbfont.c
+++ b/gs/src/zbfont.c
@@ -460,8 +460,6 @@ lookup_gs_simple_font_encoding(gs_font_base * pfont)
}
/* Get FontMatrix and FontName parameters. */
-private void get_font_name(ref *, const ref *);
-private void copy_font_name(gs_font_name *, const ref *);
private int
sub_font_params(const ref *op, gs_matrix *pmat, ref *pfname)
{
@@ -652,7 +650,7 @@ build_gs_sub_font(i_ctx_t *i_ctx_p, const ref *op, gs_font **ppfont,
/* Get the string corresponding to a font name. */
/* If the font name isn't a name or a string, return an empty string. */
-private void
+void
get_font_name(ref * pfname, const ref * op)
{
switch (r_type(op)) {
@@ -669,7 +667,7 @@ get_font_name(ref * pfname, const ref * op)
}
/* Copy a font name into the gs_font structure. */
-private void
+void
copy_font_name(gs_font_name * pfstr, const ref * pfname)
{
uint size = r_size(pfname);
diff --git a/gs/src/zfcid0.c b/gs/src/zfcid0.c
index 5be7648f5..02249dac3 100644
--- a/gs/src/zfcid0.c
+++ b/gs/src/zfcid0.c
@@ -360,7 +360,7 @@ zbuildfont9(i_ctx_t *i_ctx_p)
int code = build_proc_name_refs(&build, NULL, "%Type9BuildGlyph");
gs_font_cid_data common;
ref GlyphDirectory, GlyphData, DataSource;
- ref *prfda;
+ ref *prfda, cfnstr, *CIDFontName;
gs_font_type1 **FDArray;
uint FDArray_size;
int FDBytes;
@@ -378,6 +378,7 @@ zbuildfont9(i_ctx_t *i_ctx_p)
if (code < 0 ||
(code = cid_font_data_param(op, &common, &GlyphDirectory)) < 0 ||
(code = dict_find_string(op, "FDArray", &prfda)) < 0 ||
+ (code = dict_find_string(op, "CIDFontName", &CIDFontName)) <= 0 ||
(code = dict_int_param(op, "FDBytes", 0, MAX_FDBytes, -1, &FDBytes)) < 0
)
return code;
@@ -443,6 +444,8 @@ zbuildfont9(i_ctx_t *i_ctx_p)
pfcid->cidata.FDBytes = FDBytes;
pfcid->cidata.glyph_data = z9_glyph_data;
pfcid->cidata.proc_data = 0; /* for GC */
+ get_font_name(&cfnstr, CIDFontName);
+ copy_font_name(&pfcid->font_name, &cfnstr);
ref_assign(&pfont_data(pfont)->u.cid0.GlyphDirectory, &GlyphDirectory);
ref_assign(&pfont_data(pfont)->u.cid0.GlyphData, &GlyphData);
ref_assign(&pfont_data(pfont)->u.cid0.DataSource, &DataSource);
diff --git a/gs/src/zfcid1.c b/gs/src/zfcid1.c
index 6bf1c29ee..1960b3d13 100644
--- a/gs/src/zfcid1.c
+++ b/gs/src/zfcid1.c
@@ -180,11 +180,12 @@ zbuildfont11(i_ctx_t *i_ctx_p)
gs_font_type42 *pfont;
gs_font_cid2 *pfcid;
int MetricsCount;
- ref rcidmap, ignore_gdir, *file;
+ ref rcidmap, ignore_gdir, *file, cfnstr, *CIDFontName;
ulong loca_glyph_pos[2][2];
int code = cid_font_data_param(op, &common, &ignore_gdir);
if (code < 0 ||
+ (code = dict_find_string(op, "CIDFontName", &CIDFontName)) <= 0 ||
(code = dict_int_param(op, "MetricsCount", 0, 4, 0, &MetricsCount)) < 0
)
return code;
@@ -251,6 +252,8 @@ zbuildfont11(i_ctx_t *i_ctx_p)
pfcid->cidata.MetricsCount = MetricsCount;
ref_assign(&pfont_data(pfont)->u.type42.CIDMap, &rcidmap);
pfcid->cidata.CIDMap_proc = z11_CIDMap_proc;
+ get_font_name(&cfnstr, CIDFontName);
+ copy_font_name(&pfcid->font_name, &cfnstr);
if (MetricsCount) {
/* "Wrap" the glyph accessor procedures. */
pfcid->cidata.orig_procs.get_outline = pfont->data.get_outline;