tgifで作られた古いepsファイルがフォントのエラーで開けない時の対処法とTEXへのとりこみ

Tgifのepsの修正

tgifで作られた古いepsファイルがフォントのエラーで開けない時の対処法。。

epsファイルがフォントが理由で開けない場合のチェック事項。。

テキストエディタでepsファイルを直接ひらく。

1. tgif で作られてるか?

%!
%%BoundingBox: 248 573 467 716
%%Title: prob_circ
%%CreationDate: Tue Sep 18 17:13:49 2001
%%Creator: Tgif-3.0J.18 by William Chia-Wei Cheng (william@cs.UCLA.edu)

こんなふうにtgifで作られてるかわかる。
- 以下のページのようなeps かチェック。
http://www.tnlab.inf.uec.ac.jp/tips/postscript.html 下みたいの状態だと今回の方法でうまくいくかも。

%%Title: OCFeucfont.ps
%%Creator: shikida@cs.titech.ac.jp, ueno@cs.titech.ac.jp
%%CreationDate: 1991-2-27
%%EndComments
% <font> OCFcopyfont <font>
/OCFcopyfont {
    dup maxlength 1 add dict begin
    {
    1 index /FID ne 2 index /UniqueID ne and
    {def} {pop pop} ifelse
    } forall
    currentdict
    end
} bind def
% <newfont> <asciifont> <kanjifont> OCFeucfont
/OCFeucfont {
      12 dict begin
    dup type /nametype eq { findfont } if
    dup /WMode known {
        dup /WMode get /WMode exch def
        WMode 1 eq {
        [0.0 1.0 -1.0 0.0 0.0 0.30] makefont
        } if
    } if
    OCFcopyfont dup begin
        /Encoding Encoding
        FMapType dup 2 eq {
        pop 128 128
        } { 5 eq {
        256 256
        } {
        /compositefont errordict /invalidfont get exec
        } ifelse
        } ifelse
        getinterval def
    end
    /kanjifont exch definefont
    exch

    dup type /nametype eq { findfont } if
    exch

    /FDepVector [ 4 2 roll ] def
    /FontType 0 def
    /FMapType 4 def
    /FontMatrix matrix def
    /Encoding [ 0 1 ] def
    /FontBBox {0 0 0 0} def
    dup /FontName exch def
    currentdict
    end
    definefont pop
} def

% <newfont> <asciifont> <kanjifont> eucfont
/eucfont {
    dup findfont
    /FMapType get 9 eq
        { CIDeucfont}
        { OCFeucfont} ifelse
} def

2. obj ファイルがある場合。

objファイルを新しいtgifで開き、保存しなおす。epsで出力すれば修正されている。

3. objファイルがない場合

以下のように修正
1. 2行ある部分の片方をコメントアウト
2. 日本語はTime-Roman- などの接頭字を消す。

% TEXT
0 setgray
newpath
   515 235 moveto 584 235 lineto 584 255 lineto 515 255 lineto
closepath 1 setgray fill
0 setgray
/Times-Roman-GothicBBB-Medium-EUC-H /Times-Roman /GothicBBB-Medium-EUC-H eucfont
/Times-Roman-GothicBBB-Medium-EUC-H findfont [17 0 0 -17 0 0] makefont setfont
   gsave
      516 251 moveto (\245\327\245\355\241\274\245\326) show
   grestore

修正後

% TEXT
0 setgray
newpath
   515 235 moveto 584 235 lineto 584 255 lineto 515 255 lineto
closepath 1 setgray fill
0 setgray
%/Times-Roman-GothicBBB-Medium-EUC-H /Times-Roman /GothicBBB-Medium-EUC-H eucfont
/GothicBBB-Medium-EUC-H findfont [17 0 0 -17 0 0] makefont setfont
   gsave
      516 251 moveto (\245\327\245\355\241\274\245\326) show
   grestore

3. 他のやり方

以下のような新しい書き方に変えてしまう
- \241\274 が8進数の文字
- move xxx が位置
- [,,] が文字の大きさなので、
下のような形にいれかえる。

% TEXT
newpath
0 setgray
   gsave
      1 setlinewidth
      430 175
       moveto
      gsave
            0 setgray
            /Ryumin-Light-EUC-H findfont dup /WMode known {dup /WMode get 1 eq {[17 0 0 -17 0 0] makefont} if} if
[20 0 0 -20 0 0] makefont setfont
            (\245\252\245\267\245\355\245\271\245\263\241\274\245\327) show
      grestore
   grestore

TEXへの取り込み

最近の2020のTEXはepsの扱いが苦手なので、うまくとりいれないと失敗する。    - 原則は, dvipdfmx を使う。

\usepackage[dvipdfmx]{graphicx}

dvipdfmxときちんとし指定しないとだめらしい。

  • 原則はincludegraphicsでよみとる

  • それでも読み取れないときは、epsファイルのソースをみて1行目が

%!

しかない場合は、

%!PS-Adobe-3.0 EPSF-3.0

とか適当に書き加える。


参考
dvipdfmx での EPS 画像挿入が最近アレな話    https://zrbabbler.hatenablog.com/entry/2014012/1390313675
LaTeX+dvipdfmx でEPS画像がずれる場合の対策
https://qiita.com/zr_tex8r/items/089b56291588f7b05b02