xref: /plan9/sys/src/cmd/gs/doc/Issues.htm (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<title>Ghostscript Open Issues.</title>
5<!-- $Id: Issues.htm,v 1.52 2005/10/20 19:46:23 ray Exp $ -->
6<link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style">
7</head>
8
9<body>
10<!-- [1.0 begin visible header] ============================================ -->
11
12<!-- [1.1 begin headline] ================================================== -->
13
14<h1>Known limitations and minor bugs.</h1>
15
16<!-- [1.1 end headline] ==================================================== -->
17
18<!-- [1.2 begin table of contents] ========================================= -->
19
20<h2>Table of contents</h2>
21
22<ul>
23<li><a href="#Known_Limitations">Known Limitations</a>
24<li><a href="#Minor_bugs">Minor bugs</a>
25<li><a href="#Driver_Issues">Specific Driver Issues</a>
26<li><a href="#Performance">Performance</a>
27<li><a href="#Differences_from_Adobe">Differences from Adobe Implementation</a>
28</ul>
29
30<!-- [1.2 end table of contents] =========================================== -->
31
32<!-- [1.3 begin hint] ====================================================== -->
33
34<p>For other information, see the <a href="Projects.htm">Development Projects list
35</a>.
36
37<!-- [1.3 end hint] ======================================================== -->
38
39<hr>
40
41<!-- [1.0 end visible header] ============================================== -->
42
43<!-- [2.0 begin contents] ================================================== -->
44
45<p>
46There are many areas that might make Ghostscript more useful or minor bugs
47that we would like to investigate and possibly fix, but for which we don't
48have enough resources. These may or may not be addressed in future releases.
49<p>
50If you would like to take responsibility for any of these issues, please
51<a href="mailto:raph@artofcode.com">contact us</a>.
52<p>
53Additional comments on implementation approaches or project goals are in
54<I>italic type like this</I>.
55<hr>
56
57<h2><a name="Known_Limitations"></a>Known Limitations.</h2>
58
59<h3>bbox device doesn't allow min coords < 0.</h3>
60Adobe eps specification doesn't say that bbox values must be positive,
61and, for example Adobe Illustrator, can create EPS files with negative bboxes.
62In such case, Ghostscipt returns zero instead of proper negative number.
63<p>
64Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=202735"
65class="offsite">#202735</a>, March 09, 2000.
66<p>
67<I>
68This might be able to be fixed by applying a large positive translation to
69the bbox CTM which would be subtracted from coordinates passed to the target
70device as well as from the results the bbox device reports.
71<p>
72If coordinates for the ImagingBBox[0] and [1] values, then negative
73values are handled, but this is not reliable since there are places in
74the graphics library that depend on first quadrant coordinates.
75</I>
76
77<h3>Error messages are too low level and confusing.</h3>
78
79<p>
80Although technically correct many error messages are confusing for
81end users. Some commonly reported examples are listed below.
82
83<p>
84When pdfwrite device cannot open the output file it fails with:
85<pre>**** Unable to open the initial device, quitting.</pre>
86
87When CIDFont-CMap pair required by PDF file is not available GS
88fails with:
89<blockquote><pre>/undefinedresource in --findresource--</pre></blockquote>
90
91
92<h3>pswrite device generates low level PostScript.</h3>
93
94<p>
95pswrite and epswrite devices reduce everything to path, fill, stroke, clip
96image, and imagemask operations. Although the resulting file
97prints OK it produces unsatisfactory results when scaled,
98distilled or imported into graphic editors.
99The file can easily exceed 4GB and hit file size limits
100in some applications or operation systems. Handling of big files is
101slow.
102<p>
103Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=615165"
104class="offsite">#615165</a>, September 26, 2002.
105<hr>
106<h2><a name="Minor_bugs"></a>Minor Bugs.</h2>
107
108<h3> Bad JPEG stream in PDF generated when source ends prematurely</h3>
109When GS converts the source image to JPEG stream in PDF file and the
110source data end prematurely, it generates bad JPEG stream.
111tiff2ps from libtiff distribution often generates such files.
112<p>
113One potential workaround is to use -dAutoFilterColorImages=false and
114-dColorImageFilter=/FlateEncode.
115<p>
116Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=228808"
117class="offsite">#228808</a>, Jan 15, 2000.
118<p>
119<I>
120JPEG stream writes image dimensions in JPEG header when the stream is created.
121When the source data end the dimensions are not updated. There may be other
122problems too.
123</I>
124
125<h3> Some attributes of Catalog object are lost during PDF to PDF conversion</h3>
126Dests, OpenAction, URI, PageMode, ViewerPreferences are lost during PDF to PDF
127conversion. Other attributes have not been checked.
128<p>
129<I>
130The loss happens diring PDF interpretation. GS can generate these attributes
131from pdfmark's.
132</I>
133<p>
134March 25, 2001.
135<h3>ps2pdf ignores transfer functions in shaded fill</h3>
136ps2pdf ignores transfer functions in the shaded fill but
137uses them for vector objects. The following sample program
138has 2 shaded fills and 2 rectangles that should have the
139same color as the left end of the shaded fill.
140<blockquote><pre>
141
142%!
143&lt;&lt;/PageSize [612 200] /Policies&lt;&lt;/PageSize 1&gt;&gt; &gt;&gt;setpagedevice
144612 1 scale
145/grad
146{ gsave
147  0 0 1 100 rectclip
148  &lt;&lt;
149	  /ColorSpace [/DeviceCMYK]
150	  /Domain [0 1]
151	  /Coords [0 0 1 0]
152	  /Extend [false false]
153	  /Function
154	  &lt;&lt; /FunctionType 3
155		  /Domain [ 0 1]
156		  /Functions
157		  [ &lt;&lt;
158			  /FunctionType 2
159			  /N 1
160			  /C0 [ 0 0.5 0 0 ]
161			  /Domain [ 0 1]
162			  /C1 [0.5 0 0 0]
163		  &gt;&gt; ]
164		  /Bounds []
165		  /Encode [0 1]
166	  &gt;&gt;
167	  /ShadingType 2
168  &gt;&gt; shfill
169
170  0 0.5 0 0 setcmykcolor
171  0 0 0.1 50 rectfill
172  grestore
173} def
174
175grad
176{1 exch 2 div sub} settransfer
1770 100 translate
178grad
179showpage
180
181</pre></blockquote>
182Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=232334"
183class="offsite">#232334</a>, February 14, 2001.
184
185<h3>ResourceFileName gives wrong result with Font category.</h3>
186The following sequence:
187
188<blockquote><pre>
189/Font /Category findresource begin
190/CharterBT-Roman 255 string ResourceFileName =
191end
192</pre></blockquote>
193
194Gives the results:
195<pre>
196        /Resource/Font/CharterBT-Roman
197</pre>
198
199This should be a valid platform specific file name and path such as:
200<pre>
201        f:/afpl/fonts/bchr.pfa
202</pre>
203Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=233403"
204class="offsite">#233403</a>, February 21, 2001.
205<h3>GS doesn't handle names of separations with HalftoneType 5.</h3>
206PLRM3 says, that HalftoneType 5 may use user defined
207names of separations. Neither zht2.c nor cmd_put_drawing_color in
208gxclpath.c can handle this. GS chooses default halftone component
209for any non-standard separation name.
210<p>
211Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=406643"
212class="offsite">#406643</a>, March 7, 2001.
213
214<h3> PDF 1.4 images don't deallocate all memory </h3>
215
216<p>
217The pdf14_begin_typed_image() function in the PDF 1.4 device creates
218a marking device, but this is not freed on end_image. The garbage
219collector will free it, so it's not a real memory leak, but it would
220still be nicer to free it explicitly.
221
222<h3> Truetype fonts are written with incorrect table checksums </h3>
223
224<p>
225psf_write_truetype_data() writes truetype fonts with incorrect
226checksums on most tables. Most truetype interpreters ignore these
227so in practice the issue hasn't been a problem. Nevertheless,
228Ghostscript is embedding off-spec fonts in pdf documents.
229
230<p>
231A complete fix should generate font data in 2 passes: the
232first pass computes the checksums, the second one
233really writes data. Fonts can be very large, so
234buffering the entire font is not a good solution. The
235checksums can't be modified after the data is written
236because the output stream may not be positionable
237(likely it's a FlateEncode filter).
238
239<p>
240<i>Igor suggests implementing a special encoding filter for
241checksums, and executing the body of
242psf_write_truetype_data twice: first with the checksum
243filter, second with the real output stream. After a TT
244table is completed, its checksum to be taken from the
245filter and to be put into the 'tables' array.</i>
246
247<p>
248Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=615620"
249class="offsite">#615620</a>, September 27, 2002.
250
251<h3> save restore fails from the command line </h3>
252
253<p>
254Entering 'save' followed by 'restore' from the interactive
255Ghostscript prompt (on separate lines) generates an /invalidrestore
256exception. It shouldn't. This is a long standing issue.
257
258<p>
259The problem is that the string that is used
260for command line input by the 'executive'
261processing still exists when the 'restore'
262happens, but this string is brought into
263existence after the 'save' operation, thus
264an causing an invalidrestore.
265
266<p>
267Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=603689"
268class="offsite">#603689</a>, September 2, 2002.
269
270<h3> Failure to repair incorrect component ids in JPEG images </h3>
271
272<p>There are PDF files in the wild containing JPEG images with
273incorrect component id tags. Ghostscript currently displays these
274files incorrectly, but in the past the files displayed fine. The
275problem is not in Ghostscript itself, though, but in the libjpeg
276library.
277
278<p>Behavior changed in recent libjpeg versions; libjpeg version 6a
279ignored the component ids. As of version 6b, libjpeg interprets the id
280tags, but creates garbage output when they're invalid. We developed a
281<a
282href="http://ghostscript.com/pipermail/gs-code-review/2004-June/004579.html"
283class="offsite">patch
284to libjpeg 6b</a> which makes the decoding more robust. We are not
285aware of anybody maintaining new libjpeg releases, so we include the
286patch here in the hope that people can apply it themselves, and that
287in the event that there is a future libjpeg update, that it will
288include this patch as well. Linux distributions are especially
289encouraged to apply this patch to the system libjpeg package.
290
291<p>Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=406643"
292class="offsite">#686980</a>, July 31, 2003.
293
294<hr>
295
296<h2><a name="Driver_Issues"></a>Driver Issues.</h2>
297
298<h3> [ ] Missing text in landscape mode.</h3>
299Using GSWIN32C.EXE with djet500 to print a file in landscape mode
300on a HP 2000C, the first 3 characters on the left margin are missing.<br>
301When the postscript file is editted to use a larger offset (1st moveto
302parameter), the text appears ok.<br>
303When the postscript file is sent to a printer with a builtin postscript
304interpreter, it prints ok.
305<p>
306Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=206652"
307class="offsite">#206652</a>
308<p><I>
309A possible work around is to send the following
310postscript file to the printer prior to printing the problem
311file.  This works but it leaves a .5" margin at the top
312and left which is may be ok for some uses.
313</I>
314<blockquote><pre>
315
316%!PS-Adobe-2.0
317% Reset the offset and margins.
318&lt;&lt;
319    /PageOffset [-12 -18]
320    /Margins [0 0]
321    /.HWMargins [0 0 0 0]
322&gt;&gt;
323setpagedevice
324</pre></blockquote>
325
326<I>
327This is an instance of the endless struggle with printer margins, especially
328for HP printers. The HP drivers are inconsistent as to whether the user space
329(0,0) should be the physical corner of the page (as it is in PostScript) or
330the corner of the printable area, and if the latterm whether the page should
331be clipped or scaled.
332</I>
333<p>
334
335<h3> User request for pdfwrite to convert all colors.</h3>
336
337<p>
338Currently, pdfwrite only converts fill/stroke/text/imagemask colors to the
339color space defined by ProcessColorModel, not colors in images.  A user
340requested that it convert all colors, including images.  (Feature request
341<a href="http://bugs.ghostscript.com/show_bug.cgi?id=485498"
342class="offsite">#485498</a>)
343<p>
344<i>
345ProcessColorModel is a stopgap until pdfwrite handles device-dependent
346vector/text/mask colors properly -- i.e., no longer converts them to a
347single color space.  I.e., this request is for a significant enhancement,
348not a bug fix.
349</i>
350
351<hr>
352
353<h2><a name="Performance"></a>Performance.</h2>
354
355<h3>Incremental loading for CIDFontType 2 and TrueType fonts.</h3>
356
357Entire TrueType outline data in CIDFontType 2 and TrueType fonts are
358loaded into memory at once.  Incremental loading of the outline data is
359indispensable for practical use of Asian fonts.
360<p>
361There is one other type of CID-keyed font that should also be
362loaded incrementally: CFF CIDFontType0, i.e., a CIDFontType 0
363font represented using the compact binary CFF format. This is
364important because this is one of the two variants of Asian OpenType
365fonts (the other is essentially the same as TrueType). Ghostscript
366already supports both of these OpenType variants, but not with
367incremental loading.
368<p>
369Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=223992"
370class="offsite">#223992</a>, November 30, 2000.
371<p><I>
372We suggest that anyone who would like to work on this project
373start by looking at how CIDFontType 0 fonts do incremental loading
374(lib/gs_cidfn.ps and src/zfcid0.c). Probably much of this
375code can be also be used with CIDFontType 2 and TrueType fonts.
376</I>
377
378<hr>
379
380<h2><a name="Differences_from_Adobe"></a>Differences from Adobe Implementation.</h2>
381
382<h3>pdfwrite + TT font => Acrobat 3.x for Windows gives error</h3>
383
384Running ps2pdf12 on the file test1.ps produces a PDF on which Acrobat
3853.x for Windows complains about not being able to find or create a
386particular TrueType font that is embedded in the PDF file.  However,
387Acrobat 3.x for other platforms, and Acrobat 4.x for all platforms,
388accepts the file.
389<p>
390Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=201955"
391class="offsite">#201955</a>, February 14, 2000.
392
393<p><I>
394Since Acrobat 3 is superseded by Acrobat 4 which is available at no
395charge, and the file produced by Ghostscript meets published PDF
396specification, this will most likely be left as is.
397</I>
398
399<h3> Inconsistent handling of /Orientation.</h3>
400PLRM says "The dictionary returned by currentpagedevice always
401contains an entry for every parameter supported by the device".
402GS prints both messages in the following program:
403
404<blockquote><pre>
405%!
406currentpagedevice /Orientation known not
407{ (This printer does _not_ support Orientation.) =
408}
409if
410&lt;&lt;/Orientation 1gt;gt; setpagedevice
411currentpagedevice /Orientation known
412{ (Err... wait... it does.) =
413}
414if
415%%EOF
416</pre></blockquote>
417Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=220967"
418class="offsite">#220967</a>, October 31, 2000.
419<p><I>
420The handling of Orientation is a mess. The PLRM says quite explicitly
421that it is only supported for roll devices, where the page size
422alone doesn't give enough information to decide whether to rotate
423the page.
424<p>
425The reason that Ghostscript accepts it for other devices at all
426is twofold: displays are like roll media in that they don't have
427an inherent orientation, and almost none of the other Ghostscript
428devices actually specify their page sizes. Both of these reasons
429are now poorly motivated: displays should behave like
430portrait-orientation devices (albeit with variable page dimensions),
431rotating the image if the requested page width is greater than
432the height, and now that setpagedevice and the Resource machinery
433are fully implemented, all printer drivers should be updated
434to provide the paper size information. Once these fixes are made
435(which will probably have some repercussions other places in
436the code), Ghostscript will handle Orientation properly.
437<p>
438This should be addressed when the "setpagedevice in C" project is
439completed since part of this will require printer drivers to make
440page size information available to the setpagedevice logic.
441</I>
442
443<h3>Filesystem implementation differences.</h3>
444Adobe implementations often treat the filesystem as flat. This means that the
445path separator characters are not handled as special characters in filenames.
446The PLRM states that file names are implementation specific (section 3.8.2)
447and Ghostscript currently implements filenames that conform with the underlying
448operating system as is stated in this section about the %os% device. This
449can result from behaviour that is different from Adobe printer implementations.
450<br><br>
451<I>
452Current implementation is incompatible with most font installers. Installers
453expect that:
454<ul>
455<li>"filenameforall" enumerates all files in all directories using the relative path name.
456Directory names, including . and .. are not enumerated
457</ul>
458<ul>
459<li>characters not supported on the platform are encoded.
460</ul>
461<ul>
462<li>"(w) file" operator creates directories if necessary.
463</ul>
464</I>
465
466<h3>Cannot load Adobe's fonts. </h3>
467The following program fails with Adobe fonts:
468
469<blockquote><pre>
470(C*)
471{ cvn findfont pop
472} 255 string /Font resourceforall
473</pre></blockquote>
474Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=226462"
475class="offsite">#226462</a>, December 20, 2000.
476<p>
477<I>
478The 'findfont' operator and '/Font resourceforall' are very difficult to
479keep consistent, because the same logic algorithms must be implemented
480in two different ways. The problem is likely to be in lib/gs_fonts.ps,
481lib/gs_res.ps, and lib/gs_cidcm.ps.
482</I>
483<h3> There's no %ram% device.</h3>
484GS doesn't have %ram% device reguired on all Level 3 products.
485It is documented in PS Supplement 3010 and 3011 dated August 30, 1999
486<br>
487Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=226943"
488class="offsite">#226943</a>, December 27, 2000.
489<p>
490<I>
491This should be implemented using the (disk) file system rather than
492actual RAM, at least initially, since that will be easy.
493<br>
494On Unix, it should be implemented with a directory /tmp/$$/ (where
495$$ is the process id), which Ghostscript should delete when it exits.
496</I>
497
498<h3> pdfwrite doesn't recognise the image type by content</h3>
499Currently pdfwrite uses JPEG compression for any 8 bit per component
500images >= 64 pixels in both dimensions.
501<p>
502<I>
503pdfwrite needs to be changed to use a reasonable algorithm for deciding
504between JPEG and Flate compression, probably based on sharp vs. smooth
505color transitions in the image; in case of uncertainty, it should use Flate.
506</I>
507<p>
508Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=226391"
509class="offsite">#226391</a>, December 19, 2000.
510<p>
511
512
513<h3> ps2ascii can't handle incremental fonts</h3>
514ps2ascii fails with rangecheck on incremental fonts.
515Need to recognise incremental fonts and say that incremental
516fonts are impossible to convert to ASCII.
517<p>
518Bug <a href="http://bugs.ghostscript.com/show_bug.cgi?id=441959"
519class="offsite">#441959</a> keeps good test data for this.
520<p>
521
522
523<h3> Buffering in input filters</h3>
524
525The following program prints differently to stdout on GS and Adobe :
526<p>
527<blockquote><pre>
528%!
529/proc
530  { currentfile =string readline pop
531    dup ==
532    (%) anchorsearch { pop } if
533  } bind def
534/test
535  { //proc /ASCIIHexDecode filter
536    3 string readstring pop ==
537  } bind def
538
539(start) ==
540
541test
542%31
543%32
544%33
545%34
546%35
547%36
548%37
549%38
550%39
551
552(stop) ==
553
554%%EOF
555</pre></blockquote>
556<p>
557<I>
558Adobe fills entire input buffer of ASCIIHexDecode with procedure's output,
559before passing data to ASCIIHexDecode, and without knowledge how much data
560does ASCIIHexDecode want. GS does know the size of data requested,
561so as the procedure is called exact number of times. Thus, GS is more conservative.
562</I>
563<p>
564Anoter useful test to be made by repeating lines %31-%39 hundred times,
565without intermediate empty lines.
566<p>
567
568<h3>Improper handling of hybrid fonts.</h3>
569
570Hybrid fonts are described in section 9.2 of the "Adobe Type 1 Font Format" book.
571Such fonts cannot load into global VM due to internal usage of <I>save/restore</I>
572(and should do into local VM).
573Hybrid fonts can be recognized by the appearance of the word 'hires' with
574a pre-scan over the font, the same way that .findfontvalue works now.
575
576<!-- [2.0 end contents] ==================================================== -->
577
578<!-- [3.0 begin visible trailer] =========================================== -->
579<hr>
580
581<p>
582<small>Copyright &copy; 2000-2002 artofocode LLC.  All rights reserved.</small>
583
584<p>
585<small>
586This software is provided AS-IS with no warranty, either express or
587implied.
588
589This software is distributed under license and may not be copied,
590modified or distributed except as expressly authorized under the terms
591of the license contained in the file LICENSE in this distribution.
592
593For more information about licensing, please refer to
594http://www.ghostscript.com/licensing/. For information on
595commercial licensing, go to http://www.artifex.com/licensing/ or
596contact Artifex Software, Inc., 101 Lucas Valley Road #110,
597San Rafael, CA  94903, U.S.A., +1(415)492-9861.
598</small>
599
600<p>
601<small>Ghostscript version 8.53, 20 October 2005
602
603<!-- [3.0 end visible trailer] ============================================= -->
604
605</body>
606</html>
607