Search code examples
pdf-generationghostscriptpostscript

How to make croatian characters show correctly on all platforms in a PDF?


I've created this small Postscript to create a test page:

100 100 moveto
/Courier findfont 10 scalefont setfont
(This is croatian characters test: ) show
/scaron glyphshow
/dcroat glyphshow
/ccaron glyphshow
/cacute glyphshow
/zcaron glyphshow
/Scaron glyphshow
/Dcroat glyphshow
/Ccaron glyphshow
/Cacute glyphshow
/Zcaron glyphshow
showpage

I ran it through ps2pdf shell on Linux (on Fedora 13 and Enterprise release 5), and the resulting PDF shows up good on these systems. However, if I try to open the document on a Windows system (tested on Windows XP, Vista and 7), the characters /dcroat, /ccaron, /cacute, /Dcroat, /Ccaron and /Cacute don't show up at all! Can someone please point me in the right direction about where the problem might be and perhaps the solution?

I've run this through multiple versions of GS, the latest being GPL Ghostscript 8.71 (2010-02-10). The result is always the same. The resulting PDF can be found here (scroll down on the page to see text).


Solution

  • Use gs (Ghostscript) instead of ps2pdf to convert your PostScript file to PDF. (ps2pdf is only a simple wrapper around a Ghostscript commandline anyway.)

    As you are using Courier (which is one of the 'base 14' fonts), Ghostscript will by default NOT embed the font into the PDF. That means, you'll have to use some additional commandline magic to enforce the Courier embedding:

    gs \
      -o croatian-glyphs.pdf \
      -sDEVICE=pdfwrite \
      -c ".setpdfwrite <</NeverEmbed [ ] /AlwaysEmbed [/Courier]>> setdistillerparams" \
      -f croation-glyphs.ps
    

    Note, that when I run this command on my Mac, I see only 4 croatian characters in the output (scaron, Scaron, zcaron and Zcaron). The reason for this is: my Courier here does not have all of the croatian glyphs which were asked for (and hence cannot embed them).

    However, if you run this command on a system which has a Courier including the other glyphs, and if you pass me your resulting PDF, I could see the glyphs just fine (since the font, or at least the subset of glyphs in use, is now embedded in the PDF).