ps2pdf* で /undefinedresourceエラーが出た時の対処方
多分、常識なのかも知れないですが、ドキュメントを読まない私ははまってし
まったので…
ghostscript 8.51 で、CIDフォントを TrueType フォントで代替するよう設定
している時に、ps2pdf* で
Error: /undefinedresource in --findresource--
Operand stack:
Ryumin-Light-EUC-H Font Ryumin-Light-EUC-H (Ryumin-Light-EUC-H) 12 Ryumin-Light EUC-H EUC-H Ryumin-Light Ryumin-Light Ryumin-Light --nostringval-- (r) --nostringval-- CMap (r) CMap (r)
Execution stack:
......
のような感じのエラーで変換できない場合は、次のどれかを行うとエラーを起
こさずに変換できます:
・環境変数 GS_FONTPATH に TrueTypeフォントのあるディレクトリを設定する:
GS_FONTPATH=/usr/share/fonts/ja/TrueType; export GS_FONTPATH
・-sFONTPATHオプションで TrueTypeフォントのあるディレクトリを渡す:
ps2pdfwr -sFONTPATH=/usr/share/fonts/ja/TrueType input.ps output.pdf
・環境変数 GS_LIB にTrueTypeフォントのあるディレクトリを指定する:
GS_LIB=$prefix/share/ghostscript/8.51/lib:/usr/share/fonts/ja/TrueType
export GS_LIB
・-Iオプションで TrueTypeフォントのあるディレクトリを指定する:
ps2pdfwr -I$prefix/share/ghostscript/8.51/lib:/usr/share/fonts/ja/TrueType \
input.ps output.pdf
(Linux Distribution の中には、勝手に GS_LIB を設定するものもあるようで、
それは unset してからとりかかった方がよさそうです)
なお上記例は、 $prefix/share/ghostscript/8.51/lib/cidfmap に
/Ryumin-Light <<
/FileType /TrueType
/Path (/usr/share/fonts/ja/TrueType/tlmincho.ttc)
/SubfontID 0
/CSI [(Japan1) 3]
>> ;
と書いてあったとします。
これらの解はどこからくるかと言うと:
・$prefix/share/ghostscript/8.51/doc/Use.htm#CIDFontSubstitution から、
/Path string A path to a TrueType font file. This must be an absolute
path. If using -dSAFER, the directory containing the font
file must be on one of the permitted paths.
・$prefix/bin/ps2pdfwr では、 OPTIONS="-dSAFER" を指定している。
・"the permitted paths" って何?、という訳で
$prefix/share/ghostscript/8.51/doc/Use.htm#Safer を見ると、
-dSAFER
Disables the deletefile and renamefile operators, and the ability to open
piped commands (%pipe%cmd) at all. Only %stdout and %stderr can be opened
for writing. Disables reading of files other than %stdin, those given as a
command line argument, or those contained on one of the paths given by
LIBPATH and FONTPATH and specified by the system params /FontResourceDir
and /GenericResourceDir.
という訳で、LIBPATH なり FONTPATH (これらの意味も Use.htmに書いてある)を
与えれば良いようです。
----------------------------------------------------------------------
tesigana@mtf.biglobe.ne.jp
Fnews-brouse 1.9(20180406) -- by Mizuno, MWE <mwe@ccsf.jp>
GnuPG Key ID = ECC8A735
GnuPG Key fingerprint = 9BE6 B9E9 55A5 A499 CD51 946E 9BDC 7870 ECC8 A735