Bug 690960 - Issue with pswrite device: Thai characters with accent are not printed at the correct place
Summary: Issue with pswrite device: Thai characters with accent are not printed at the...
Status: NOTIFIED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Writer (show other bugs)
Version: master
Hardware: All AIX
: P2 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-24 20:43 UTC by Subrahmanyan K.H.
Modified: 2011-10-02 02:35 UTC (History)
0 users

See Also:
Customer: 130
Word Size: ---


Attachments
thai_input.ps (604.34 KB, application/postscript)
2009-11-24 20:44 UTC, Subrahmanyan K.H.
Details
thai_output_ps.ps (562.22 KB, application/postscript)
2009-11-24 20:45 UTC, Subrahmanyan K.H.
Details
thai_output_pdf.pdf (414.24 KB, application/pdf)
2009-11-24 20:46 UTC, Subrahmanyan K.H.
Details
screen_shot.jpg (2.53 MB, image/jpeg)
2009-11-24 20:49 UTC, Subrahmanyan K.H.
Details
gs870_output.ps (606.57 KB, application/postscript)
2009-11-27 00:32 UTC, Subrahmanyan K.H.
Details
Test of accent glyphs in Distiller (120 bytes, text/plain)
2010-09-22 12:49 UTC, Ken Sharp
Details
Result of accent test (59.01 KB, application/download)
2010-09-22 12:50 UTC, Ken Sharp
Details
Original speciment file modified to use the Acrobat font name (604.36 KB, application/postscript)
2010-09-22 12:51 UTC, Ken Sharp
Details
Distiller otuptu using modified input file (245.10 KB, application/download)
2010-09-22 12:53 UTC, Ken Sharp
Details
Test file to draw all glyphs (0x00 -> 0xffff) from the spciment font (1.01 KB, application/postscript)
2010-09-22 12:54 UTC, Ken Sharp
Details
PDF fiel produced by Adobe Acrobat from the glyph test program (13.84 MB, application/download)
2010-09-22 13:00 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Subrahmanyan K.H. 2009-11-24 20:43:29 UTC
We have customer Postscript document, which has Thai characters with accent.
When we tried to convert this using Ghostscript (ps->ps using pswrite device), 
the Thai characters (accents) are not printed on the correct place. 
A Thai accent (which has its own character mapping) and another Thai character 
(with another character mapping) form together a special character. Apperently 
if the character is above or below the wrong character, the combination of the 
two characters get a different meaning. 

This is a showstopper for our customer now. This is a critical issue for the 
customer and we hope we can get the fix soon.


GS Version tested: GS8.63
Platform tested: AIX 5.3 (but seems to be there on all platforms)
GS Command used:
gs -sDEVICE=pswrite -I/hp/om/lib/FONTS/Unicode/Resource -
I/hp/om/lib/FONTS/Unicode -I/hp/om/lib/FONTS/Soft_Horizons -I/hp/om/lib/PS -
dBATCH -dNOPAUSE -dSAFER -dSHORTERRORS -dWRITESYSTEMDICT -dGHOSTSCRIPT -
dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -sOutputFile=thai_output.ps  
thai_input.ps

The Andale font which is used here, is already shared with Artifex earlier.

Please let us know if you need any more information.

I will attached the input and output files.

Thanks
Subbu
Comment 1 Subrahmanyan K.H. 2009-11-24 20:44:31 UTC
Created attachment 5711 [details]
thai_input.ps

Input Postscript document.
Comment 2 Subrahmanyan K.H. 2009-11-24 20:45:29 UTC
Created attachment 5712 [details]
thai_output_ps.ps

pswrite output from GS, where the issue can be seen.
Comment 3 Subrahmanyan K.H. 2009-11-24 20:46:30 UTC
Created attachment 5713 [details]
thai_output_pdf.pdf

PDF output file, where all the characters are correct.
Comment 4 Subrahmanyan K.H. 2009-11-24 20:49:19 UTC
Created attachment 5714 [details]
screen_shot.jpg

Screen shot showing both correct and wrong output.
Few wrong characters are marked.
Comment 5 Alex Cherepanov 2009-11-24 21:49:35 UTC
We need the font but global search on Artifex servers so far was
unsuccessful. The font can be attached to the bug report and marked
"private" to restrict the access to the font to Artifex employees
and contractors.

Bug 690118 may be related to this bug report.
We have an Andale font in /home/support/688799/amwt_f1_v4.05.ttf
but it may be unrelated to this problem.
Comment 6 Subrahmanyan K.H. 2009-11-24 22:00:59 UTC
Created attachment 5715 [details]
amwt_f1.ttf

font used in the test file.
This is used with CID reference.
This is the reference used in the cidfmap file

/AndaleMonoWT << /FileType /TrueType /Path
(/hp/om/lib/FONTS/Unicode/amwt_f1.ttf) /SubfontID 0 /CSI [(Identity) 1] >> ;
Comment 7 Henry Stiles 2009-11-25 09:02:04 UTC
Looks like there are business issues to be resolved before this problem can be
given customer level priority.  Please contact Miles Jones.
Comment 8 Subrahmanyan K.H. 2009-11-27 00:32:40 UTC
Created attachment 5722 [details]
gs870_output.ps

With GS8.70 PS output, the output is even worse, the thai characters are not
coming properly at all.
Comment 9 Marcos H. Woehrmann 2010-08-05 16:42:21 UTC
The pswrite device is obsolete and won't be maintained.  We suggest switching to to the ps2write device.
Comment 10 Ray Johnston 2010-08-05 17:28:35 UTC
Re-opening this. I am able to see the incorrect output on any device, such
as the 'display' device. It still shows up with HEAD (r11600)

Sorry, Ken.
Comment 11 Ken Sharp 2010-08-05 19:05:33 UTC
(In reply to comment #10)
> Re-opening this. I am able to see the incorrect output on any device, such
> as the 'display' device. It still shows up with HEAD (r11600)
> 
> Sorry, Ken.

If it's wrong on any device, then its not a pswrite/ps2write/pdfwrite problem, so its a font problem and should probably belong to Chris ;-) I will look tomorrow.

wrt Comment #7 are the business issues now resolved ? I believe so, but if anyone knows differently, now's the time to say.
Comment 12 Ken Sharp 2010-08-06 15:06:32 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > Re-opening this. I am able to see the incorrect output on any device, such
> > as the 'display' device. It still shows up with HEAD (r11600)
> > 
> > Sorry, Ken.
> 
> If it's wrong on any device, then its not a pswrite/ps2write/pdfwrite problem,
> so its a font problem and should probably belong to Chris ;-) I will look
> tomorrow.

The first thing that's wrong is using 'Identity' in the cidfmap file, it should be 'Unicode'. Without that the CID decoding won't work properly, which is almost certainly why comment #7 says the output is even worse with 8.70.

The output for me after that change matches the 'wrong' output in the customer screenshot. 

However, I am unable to see how the 'correct' PDF was obtained, Acrobat won't use the TrueType font as a replacement for the CIDFont, and Ghostscript's pdfwrite device unsurprisingly produces the same output as the rendering devices.

At the moment I can't say that this is a GS problem as opposed to a font problem, I would need to see the font supplied being used in some way that proves it does work.
Comment 13 Ken Sharp 2010-09-22 12:47:24 UTC
I do not see any evidence of a bug in Ghostscript here. The Thai glyph accents are shown as glyphs in their own right, the accented glyphs are not composite glyphs, nor are they unique glyphs.

In essence they follow this pattern:

Draw a glyph

Store the current point
Draw an accent glyph
Restore the saved current point
Draw the base glyph

Draw a glyph

And so on. This works if the accented glyphs are drawn above the baseline, but to the right of the origin, and have a positive horizontal advance.

The accent glyphs in the supplied font are drawn above the baseline, and with a positive horizontal advance, but are drawn to the left of the origin. These glyphs are mean to be used to draw accented glyphs by following this sequence:

Draw a glyph

Draw a base glyph
Draw an accent glyph

Draw a glyph

Because the accents are drawn to the left of the origin they effectively are drawn over the *preceding* glyph, and the horizontal advance moves the current point to the correct position for the next glyph.


We have not been supplied with the PDF file which shows how the output should look (just a screenshot of it), nor instructions on how to produce this file ourselves from the supplied font and test file, so its impossible to say if the same PostScript file and font was used to construct that PDF file. However....

With some effort I have been able to make Acrobat Distiller use the supplied font. The font is not in fact called AndaleMonoWT, it is called AndaleMonoWTG (possibly this suggests that it is not the required font).

If I install the font so that Acrobat Distiller can use it, and then run the supplied thai_input.ps test file, it of course fails, because the font has the wrong name. Altering all occurrences of the font name in thai_input.ps so that the name is correct, and running the file does produce valid output, however the glyphs displayed are not Thai glyphs (I'm not certain what they are).

So obviously the font encoding in Distiller is different to that present in the PostScript file.

So I abandoned the supplied test file and wrote a PostScript program to render every glyph from 0x0000 to 0xffff. On page 11 of the resulting file can be found the Thai glyphs and they show quite clearly (rows 6 and 7) that the accent glyphs are positioned to the left of the origin.

By using the encoding now available to me I was able to reproduce the first couple of glyphs and the first accent using Acrobat Distiller. This again shows quite clearly that the accent is positioned over the preceding glyph.


So, as far as I can tell Ghostscript is working perfectly correctly. I do not believe it is possible to use the supplied font and PostScript file to produce the output which is indicated as the desirable result. I don't know how the PDF file which is apparently showing the correct result was obtained, but I don't see how it could have been created using the supplied font and test file, nor do I think it could have been created using Adobe Acrobat from those sources.


I will attach here the PostScript program which draws the glyphs (glyph test.ps), the PDF file produced by running that through Adobe Acrobat Distiller, a test program using the Acrobat font encodings (Acrobat accent test.ps) and the resutl of running that through Acrobat Distiller (Acrobat accent test.pdf) and finally the modified that-input.ps which uses the correct font name for Acrobat and the result of running this file through Acrobat Distiller.
Comment 14 Ken Sharp 2010-09-22 12:49:08 UTC
Created attachment 6743 [details]
Test of accent glyphs in Distiller

PostScript file using Acrobat encodings and font name to demonstrate the positioning of the accent glyphs
Comment 15 Ken Sharp 2010-09-22 12:50:09 UTC
Created attachment 6744 [details]
Result of accent test

Output from Adobe Acrobat Distiller using the AndaleMonoWTG font and the PostScript test file intended to display the accent glyph positioing
Comment 16 Ken Sharp 2010-09-22 12:51:58 UTC
Created attachment 6745 [details]
Original speciment file modified to use the Acrobat font name

Original specimen file, modified to use the font name AndaleMonoWTG instead of AndaleMonoWT so that it can be used with the supplied font and tested using Acrobat Distiller
Comment 17 Ken Sharp 2010-09-22 12:53:22 UTC
Created attachment 6746 [details]
Distiller otuptu using modified input file

Output from Adobe Acrobat Distiller of the original specimen file modified to use the font name expected by Adobe Acrobat (AndaleMonoWTG)
Comment 18 Ken Sharp 2010-09-22 12:54:49 UTC
Created attachment 6747 [details]
Test file to draw all glyphs (0x00 -> 0xffff) from the spciment font

A PostScript file which draws all the glyphs (range 0x00 to 0xffff) from the font AndaleMonoWTG, 256 glyphs per page, 256 pages.
Comment 19 Ken Sharp 2010-09-22 13:00:34 UTC
Created attachment 6748 [details]
PDF fiel produced by Adobe Acrobat from the glyph test program

Output from Adobe Acrobat of the glyph test program