Bug 706478

Summary: CIDFont rendered incorrectly for PDF
Product: Ghostscript Reporter: Richard <rlescak>
Component: PDF WriterAssignee: Ken Sharp <ken.sharp>
Status: RESOLVED FIXED    
Severity: normal CC: chris.liddell, ghostpdl-bugs
Priority: P4    
Version: unspecified   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: PS and Font files
rest of the test files

Description Richard 2023-03-14 11:58:18 UTC
Created attachment 23870 [details]
PS and Font files

Hi Guys,

CIDFont is rendered correctly for PNG, but displays incorrectly in PDF. 

Used commands:

   gs -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=test.png -f test.ps

   gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=test.pdf -f test.ps

Fontmap.GS additional configuration:

   /ArialUnicode   (/usr/share/ghostscript/Resource/CIDFont/Arial-Unicode) ;
   /ArialUnicode-Identity-UTF16-H   (/usr/share/ghostscript/Resource/Font/ArialUnicode-Identity-UTF16-H) ;

cidfmap additional configuration:

   /Arial-Unicode << /FileType /TrueType /Path (/usr/share/ghostscript/Resource/CIDFont/Arial-Unicode) /SubfontID 0 /CSI [(Identity) 0] >> ;

PDF result looks differently, according to our customer it should look like output in the png file.

It's reproducible at least since 9.27 to the newest versions.

PS file (test.ps) and used font files (Arial-Unicode.t1, ArialUnicode-Identity-UTF16-H.t1) in attachment.
Comment 1 Ken Sharp 2023-03-14 12:17:34 UTC
(In reply to Richard from comment #0)

> CIDFont is rendered correctly for PNG, but displays incorrectly in PDF. 

And what are you using to view the output from pdfwrite ?


> Fontmap.GS additional configuration:
> 
>    /ArialUnicode   (/usr/share/ghostscript/Resource/CIDFont/Arial-Unicode) ;
>    /ArialUnicode-Identity-UTF16-H  
> (/usr/share/ghostscript/Resource/Font/ArialUnicode-Identity-UTF16-H) ;
> 
> cidfmap additional configuration:
> 
>    /Arial-Unicode << /FileType /TrueType /Path
> (/usr/share/ghostscript/Resource/CIDFont/Arial-Unicode) /SubfontID 0 /CSI
> [(Identity) 0] >> ;


Useful to have, but since the input PDF file contains the fonts it needs (actually a single CIDFont) these are unused. The back channel otuptu from Ghostscript for me does not have any font subsitution warnings. Does it for you ?

 
> PDF result looks differently, according to our customer it should look like
> output in the png file.
> 
> It's reproducible at least since 9.27 to the newest versions.
> 
> PS file (test.ps) and used font files (Arial-Unicode.t1,
> ArialUnicode-Identity-UTF16-H.t1) in attachment.

Ah, you seem to have sent us test.pdf, not test.ps. Perhaps that's why I can't reproduce the problem ?

FWIW test.pdf was produced by Ghostscript 10.00.0
Comment 2 Richard 2023-03-14 12:22:32 UTC
Created attachment 23871 [details]
rest of the test files

Ah sorry, I haven't included all files that I wanted.
Comment 3 Richard 2023-03-14 12:38:23 UTC
To view the pdf I've used broser and/or evince
Comment 4 Ken Sharp 2023-03-14 13:31:08 UTC
To be frank I suspect the problem is that you are using a TrueType font directly and pretending that its a CIDFont (and why do both the 'font' files you sent me have a 't1' extension ? Neither of them are type 1 fonts and the filenames don't match what was in the map files).

While Ghostscript has means to do that, its essentially a heuristic operation, and what works for rendering may well not work when it comes to embedding a font in an output PDF file.
Comment 5 Richard 2023-03-14 14:50:38 UTC
Files were sent to me with the extension for some reason, however they were used normally without extension, same goes for filename inconsistencies, there were some in reproducer which I've received, however with fixed filenames it is still reproducible. 
Sorry about that I've missed missing hyphen when I was copying it here.

Well, it is true that costumer was using pretty old system/gs version when this was still working for him.

> To be frank I suspect the problem is that you are using a TrueType font
> directly and pretending that its a CIDFont 

Is there any better way to use this font? Unfortunatly I'm not aware of any.
Comment 6 Ken Sharp 2023-03-14 15:25:01 UTC
(In reply to Richard from comment #5)

> Well, it is true that costumer was using pretty old system/gs version when
> this was still working for him.

Which version previously worked ? The most likely reason is that it produced a poor quality PDF that didn't embed the font, though its impossible to know without trying it.

 
> > To be frank I suspect the problem is that you are using a TrueType font
> > directly and pretending that its a CIDFont 
> 
> Is there any better way to use this font? Unfortunatly I'm not aware of any.

No, but the point is that there is no defined way (in the PostScript specification) to use a bare TrueType font. TrueType fonts always need to be wrapped up as type 42 fonts, which contain additional information. Using them like this means Ghostscript has to guess at that extra information, and there's no guarantee it'll be correct.
Comment 7 Richard 2023-03-15 07:50:46 UTC
According to info which the costumer provided about system version he uses it was probably ghostscript 8.7.

Thank you Ken for taking a look and providing the information and your insight.
Comment 8 Chris Liddell (chrisl) 2023-03-15 17:28:34 UTC
Fixed in:
https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=346f12459aa6
Comment 9 Richard 2023-03-16 10:52:13 UTC
Great, I can confirm that it fixes the problem.
Thank you guys!