'How can I add external fonts to ghostscript?

I have a folder( in my linux machine) which contains some font files(*.ttf fonts).I am trying to add these fonts to ghostscript while running gs command to convert from postscript to pdf. What is the option to add that fonts while running gs Command.And please let me know the how -I,-sFontResourceDir,-sFONTPATH works.

I am trying the below command and I am not able to observer anything.

gs -dSAFER -dBATCH -sDEVICE=pdfwrite -sNOPAUSE -dQUITE -sOutputFile=/home/prasad/Desktop/Virtual_pdf.pdf /home/prasad/Desktop/VirtualPrinter_06_01_2017_14_00_54_670.ps

Thanks in Advance.



Solution 1:[1]

Firstly, you need to be aware that PostScript does not support TrueType fonts (Yes, it does support type 42 fonts, which are not precisely the same thing).

So adding TrueType fonts as substitutes for missing fonts (I assume this is why you want to do this) isn't guaranteed to work. The problems are to do with guessing at the character code to glyph ID mapping.

If you want to add a font 'while running Ghostscript' then you need to write a PostScript program to do it, that's kind of beyond the scope of an answer here. So I'm assuming that you actually want to add a Font to the list of fonts/substitutes maintained by Ghostscript, there are two places;

Firstly fonts are found in the fontmap.GS file, which you can find in ..../gs/Resource/Init on a Linux system. Obviously you'll have to locate the Ghostscript installation folder yourself, its usually under /usr.

Secondly, the cidfmap file in the same location lists CIDFonts and substitutes.

The format of entries in both these files is documented in comments in the files.

The -I switch is documented in the Ghostscript documentation, in use.htm, or here

FontResourceDir is documented in the same file, under 'Resource-related parameters'

-sFONTPATH is again documented in the same file under "8.2 Font Lookup" which has a rather lengthier explanation of how all these parameters interact.

Note that -dQUITE won't do anything, that's not a valid parameter, I suspect you mean -dQUIET and I wouldn't set that while trying to debug a problem personally. Also -sNOPAUSE won't do anything, because that should be -dNOPAUSE.

Solution 2:[2]

Try to add in Arguments

"-sFONTMAP=/usr/share/fonts/Fontmap.GS -sFONTPATH=../usr/share/fonts"

And you need appending in Fontmap.GS(copy existing file or find in internet) with new font, where you can provide full path to '*.ttf' file, for example:

/Tahoma     (/usr/share/fonts/tahoma.ttf)   ;

And ghostscript will be use tahoma.ttf for Tahoma font

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KenS
Solution 2 Павел К.