r/PostScript • u/AndyM48 • Mar 20 '24
Accented characters (again)
I have googled this endlessly and each time I am more confused. I have read Red Books, Green Books, Blue Books and Pink Books, but I still don't know the answer.
My PS script uses the DejaVuSansMono range of ttf fonts. A huge number of characters are included in the ttf files, but when I print text, only the basic characters print correctly. Any accented characters (for example) print as gobbledegook. So I tried changing the encoding from Standard to ISO Latin 1 as per various googled suggestions, but that made little difference. Then I converted the DejaVuSansMono ttf file to Type 42, and embedded that in my PS script. The gobbledegook changed to whatsits but still no accented characters. Anyway, I find it difficult to believe that it should be necessary to create and embed Type 42 fonts for each of the various ttf fonts that are used in the script.
May be I need to hand craft a dictionary for each font? Again, hard to believe.
I don't think it can be that difficult, can it?
View all comments
Show parent comment
2
u/MCLMelonFarmer Mar 24 '24
FWIW, this program almost does what is needed: https://github.com/scriptituk/ttf2pscid2
The only thing missing is that it expects the strings as UTF-16 and not UTF-8. But it includes a little PostScript code function that turns UTF-8 into UTF-16, so you can do:
and it works.
Since the output is created so the CIDFont cids are just the Unicode code points (identity mapping), you could also create a UTF-8 CMap that would work with any CIDFont resource output by the ttf2pscid2 program. Then you wouldn't need to convert the string before calling "show".