summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>2008-01-28 10:31:45 +0000
committerSuzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>2008-01-28 10:31:45 +0000
commit7f746a1f1877055848339e4a19152e472a1f917d (patch)
treeadb3c85cc0e20a1e0116ef0208cf64cadac6e2e9
parentff646e3f52d4e6d4d0ebcdff0de0e28378a0eaf0 (diff)
Fix: ignore the embedded font resource when PDF interpreter resolves
the unembedded font resource. DETAILS: Some PDF generators (e.g. Microsoft Office 2007 add-on to export the documents to PDF format) emits incompatible font objects with same resource name. The sample PDF in bug 689637 includes 2 "Times New Roman" font objects: one is embedded CID-keyed TrueType for Cyrillic glyphs, another is unembedded WinAnsiEncoding TrueType (possibly for empty page header or footer). When PDF interpreter resolves latter unembedded "Times New Roman", external font resource should be used (Adobe Reader does so). But current Ghostscript uses former embedded "Times New Roman", because the sample PDF includes "Times New Roman" without randomization prefix. To avoid the confusion between embedded and unembedded fonts with same name, pfont->is_resource flag (=0 embedded, =1 unembedded) is checked during font object resolution. Even if a cached font object with same name is found, it is ignored if it is embedded font. To execute this check in PostScript space (pdf_font.ps), new operator ".isregisteredfont" is introduced. This patch assumes that embedded font object in PDF is resolvable by tracking the indirect object references. If a PDF assumes name-based resolution of embedded font object (without indirect object), it may be rendered by external font resource. At present, we don't have such sample. By this patch, bug 689637 is fixed. EXPECTED DIFFERENCES: None. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@8509 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/lib/pdf_font.ps13
-rw-r--r--gs/src/zfont.c15
2 files changed, 26 insertions, 2 deletions
diff --git a/gs/lib/pdf_font.ps b/gs/lib/pdf_font.ps
index b72f5ec58..c41756a54 100644
--- a/gs/lib/pdf_font.ps
+++ b/gs/lib/pdf_font.ps
@@ -586,8 +586,17 @@ setglobal
% If the font isn't available, synthesize one based on
% its descriptor.
dup /Font resourcestatus {
- pop pop pdffindcachedfont
+ pop pop dup pdffindcachedfont
+ dup .isregisteredfont
+ % <font-resource> <fontname> <font> true % font preloaded from disk
+ % <font-resource> <fontname> <font> false % font preloaded from document
+ { exch pop false } { pop true } ifelse
} {
+ true
+ } ifelse
+ % <font-resource> <font> false % font preloaded from disk
+ % <font-resource> <fontname> true % font not loaded yet or embedded
+ {
1 index /FontDescriptor knownoget {
% Stack: font-res fontname fontdesc
dup /Flags oget
@@ -659,7 +668,7 @@ setglobal
% No descriptor available, use the default algorithm.
pdffindcachedfont
} ifelse
- } ifelse
+ } if
exch pop
} bdef
diff --git a/gs/src/zfont.c b/gs/src/zfont.c
index 6089bcbf5..fa9f2c490 100644
--- a/gs/src/zfont.c
+++ b/gs/src/zfont.c
@@ -208,6 +208,20 @@ zregisterfont(i_ctx_t *i_ctx_p)
return 0;
}
+/* <font> .isregisteredfont <bool> */
+static int
+zisregisteredfont(i_ctx_t *i_ctx_p)
+{
+ os_ptr op = osp;
+ gs_font *pfont;
+ int code = font_param(op, &pfont);
+
+ if (code < 0)
+ return code;
+ make_bool(op, pfont->is_resource);
+ return 0;
+}
+
/* <Decoding> .setupUnicodeDecoder - */
static int
@@ -237,6 +251,7 @@ const op_def zfont_op_defs[] =
{"1setcacheparams", zsetcacheparams},
{"0currentcacheparams", zcurrentcacheparams},
{"1.registerfont", zregisterfont},
+ {"1.isregisteredfont", zisregisteredfont},
{"1.setupUnicodeDecoder", zsetupUnicodeDecoder},
op_def_end(zfont_init)
};