Bug 687472 - barcode wrongly converted to type3 font
Summary: barcode wrongly converted to type3 font
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: master
Hardware: All All
: P2 normal
Assignee: Igor Melichev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-22 04:18 UTC by Jack Moffitt
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer: 1110
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Moffitt 2004-05-22 04:18:35 UTC
If you convert the attached file, the barcode gets written as a type3 font,
which messed up most of the characters.  The barcode uses setcharwidth, and the
customer thinks that it shouldn't be converted into a PDF font (Distiller
doesn't convert it).  A proposed fix from the customer is:

*** OLD/gdevpdtt.c      Wed Mar 17 18:32:38 2004
--- gdevpdtt.c  Thu Apr 29 02:21:13 2004
***************
*** 135,141 ****
             * a notdef glyph, but we don't know how to do with Type 3 fonts.
             */
        }
!       if (glyph != GS_NO_GLYPH && ch != GS_NO_CHAR) {
            gs_show_enum *penum_s;
            extern_st(st_gs_show_enum);
            gs_fixed_rect clip_box;
--- 135,141 ----
             * a notdef glyph, but we don't know how to do with Type 3 fonts.
             */
        }
!       if (glyph != GS_NO_GLYPH && ch != GS_NO_CHAR && control !=
+TEXT_SET_CHAR_WIDTH) {
            gs_show_enum *penum_s;
            extern_st(st_gs_show_enum);
            gs_fixed_rect clip_box;
Comment 1 Jack Moffitt 2004-05-22 04:19:47 UTC
Created attachment 677 [details]
barcode.ps
Comment 2 Igor Melichev 2004-05-24 00:48:33 UTC
The customer may use the suggested patch as a temporary workaround, but the 
assumption isn't good. I'll work on the problem.
Comment 3 Igor Melichev 2004-05-24 05:19:14 UTC
PLRM3 reads :
page 339 : In particular, BuildGlyph should not depend on any nonconstant
information in VM, and it should not leave any side effects in VM or on
stacks.
Page 340 : The semantics of BuildChar are essentially the same as for 
BuildGlyph.

In the supplied document a Type 3 font defines a BuildChar that generates 
images depending on a contex in the text. Thus the document doesn't comply to 
PLRM.

If we don't convert any type 3 font with charwidth, other documents will 
convert to a longer PDF, what would be a regression. A smarter method is to 
recongize glyph variation dynamically. 
Comment 4 Igor Melichev 2004-05-26 10:43:07 UTC
Created attachment 683 [details]
The unencoded barcode.ps
Comment 5 Raph Levien 2004-05-26 10:56:40 UTC
The next step should be to check whether the proposed patch writes the glyphs as
bitmaps or outlines. If the former, we shouldn't apply it as-is, but perhaps a
more sophisticated verison that detects whether there really is variability. If
outlines (with this file and the others in our test base which use
setcharwidth), then I think we should accept the patch.

The PS spec is a little ambiguous whether the source file is valid (it's
certainly dodgy), but the description in setcharwidth argues in favor.
Comment 6 Igor Melichev 2004-05-27 01:23:15 UTC
The suggested change causes differences with out restbase, some of which are 
strong regressions with -r72 :

1. "238-01.ps" The font converts to outlines, rather there is no strong 
necessity. The searchability is lost. The generated PDF imbeds a Type 3 font, 
which is empty and isn't used.

2. "Bug687044.ps" The generated PDF, gets a wrong Widths, which causes a wrong 
glyph placement. (A strong regression).

3. "InstandardBuildChar.ps" Same as (1).

4. "muur.eps" Same as (1). The generated PDF becomes so long as 26K instead 3K -
 about 8 times longer.

5. "type3xshow.eps"  Same as (1). The generated PDF becomes so long as 37K 
instead 24K.

The resolution -r300 was not tested and may discover other problems.

Due to that I do not recommend to use the patch as it is. At least it requires 
more work for (2).

Comment 7 Igor Melichev 2004-05-27 01:24:48 UTC
I meant "with our restbase".
Comment 8 Igor Melichev 2004-05-27 23:18:20 UTC
Patches
http://www.ghostscript.com/pipermail/gs-cvs/2004-May/004506.html
http://www.ghostscript.com/pipermail/gs-cvs/2004-May/004507.html
implement a dynamic recognition of Type 3 glyph variations.

Please note that rather these patches fix the problem, they open another bug 
687487 "(pdfwrite) redundant ExtGState objects". That bug isn't critical, and 
we delay it for a while.
Comment 9 Igor Melichev 2005-06-28 16:07:46 UTC
See also bug 688168 and a patch in there.