Nothin' but Slackware

バイクとLinuxに戯れる日々

2008年01月

本日のアップデート

- 土村さんの ptetex3を取り込んだ tetex-3.0パッケージを作ってアップデート

ptetex3バージョン: ptetex3-20080128
土村さんのサイト : http://tutimura.ath.cx/ptetex/

(メモ)
 普段は TeXはあまり使わないが、Slackwareでも日本語TeXが動くことを確かめるために
インストールしている。
Ghostscriptの日本語まわりがちゃんと動作しているか確認するという意味もある。

日本語印刷(縦書き文書の問題の部分的修正)

イメージ 1

イメージ 2

■日本語縦書き文書がセンターに揃わない問題の修正 (句読点位置がずれる問題とは別)

Slackware-currentのオフィシャル ghostscript-8.61 でIPAフォントを使って
縦書き文書を表示すると1枚目の画像のようになる。
ghostscriptにいくつかパッチをあてて修正したもので再度同じpsを表示すると2枚目の画像のように
正しく表示される。
テストに使用したpsファイルは http://bugs.ghostscript.com/show_bug.cgi?id=689646 にある。


関連するバグレポートとパッチは以下
BUG #689559 http://bugs.ghostscript.com/show_bug.cgi?id=689559
BUG #689304 http://bugs.ghostscript.com/show_bug.cgi?id=689304

BUG #689646 http://bugs.ghostscript.com/show_bug.cgi?id=689646
BUG #689464 http://bugs.ghostscript.com/show_bug.cgi?id=689464
BUG #689647 http://bugs.ghostscript.com/show_bug.cgi?id=689647
http://ghostscript.com/pipermail/gs-cvs/2008-January/008087.html

画像2枚目を実現するために使ったパッチは #689559 と gs-cvs-ML#008087 から
引いてきたものを使っている。Koji Otani氏のパッチに含まれる句読点位置修正は
含まれていない。

-------------------------------------------------------------------
追記) 2008-01-30
この現象がIPAフォントで見られることは確認した。さざなみフォントでは発生しない。
少なくとも以下の環境で確認。

Slackware-current with default ghostscript-8.61 :
 さざなみフォント OK
 IPA-モナー NG
Slackware-current with 対応パッチ済みの ghostscript-8.61 :
 さざなみフォント OK
 IPA-モナー OK
Fedora8 with ghostscript-8.61-6.fc8 :
 さざなみフォント OK
 IPA-モナー NG

日本語印刷(currentのオフィシャルghostscript環境の場合)- おまけ2

■ a2ps経由で日本語ベタテキストを印刷

さて、わたしの Slackware-currentは日本語ロケールを ja_JP.UTF-8 で使っている。

STEP-1 まず、Slackwareオフィシャルの a2psにパッチをあてて作り直す。
    使ったパッチは a2ps-4.13-ja_nls.patch (ネット検索すれば見つかるはず)。
    リビルドしたパッケージを upgradepkg でインストール。
    インストール後、/etc/a2ps-site.cfgの中で

    # Default encoding
    Options: --encoding=euc-jp

    の記述があるかどうか確認。なければ追記する。

STEP-2 nkfをインストール

リビルドしたa2psをa2psはUTF-8未対応なので以下のようなコマンドで印刷する。


【ja_JP.UTF-8 なテキストを印刷するとき】

$ nkf -e <印刷したいファイル> | LANG=ja_JP.eucJP a2ps -R -1 -P <プリンタ名>

例えば sylpheed上からメールを印刷するのに sylpheed内部印刷機能を使わないで
a2ps経由で印刷したいときは、sylpheedの外部印刷コマンドに以下を指定すればよい。

nkf -e %s |LANG=ja_JP.eucJP a2ps -R -1 -P <プリンタ名>

注記)a2ps のオプション -R -1 は好みに応じてつければオッケー

おしまい

日本語印刷(currentのオフィシャルghostscript環境の場合)- おまけ1

■ xpdf で日本語PDFの印刷

1. xpdfの日本語言語パックを入れておく
2. /etc/xpdfrc の最後に以下を追記

----- >8 ----- >8 ----- >8 -----
#----- begin Japanese support package (2004-jul-27)
cidToUnicode Adobe-Japan1 /usr/share/xpdf/japanese/Adobe-Japan1.cidToUnicode
unicodeMap ISO-2022-JP /usr/share/xpdf/japanese/ISO-2022-JP.unicodeMap
unicodeMap EUC-JP /usr/share/xpdf/japanese/EUC-JP.unicodeMap
unicodeMap Shift-JIS /usr/share/xpdf/japanese/Shift-JIS.unicodeMap
cMapDir Adobe-Japan1 /usr/share/xpdf/japanese/CMap
toUnicodeDir /usr/share/xpdf/japanese/CMap
### use IPA-mona (Mincho) by default
displayCIDFontTT Adobe-Japan1 /usr/share/fonts/default/TrueType/ipam-mona.ttf
# use Kochi (Gothic) if gothic font is required
displayNamedCIDFontTT ShinGo-Bold /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT ShinGo-regular /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT MidashiGo-MB31 /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT FutoGoB101-Bold /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT HeiseiKakuGo-W5 /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT HeiseiKakuGo-W9 /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT HeiseiMaruGo-W4 /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT MS-Gothic /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT HG-GothicB /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT Kochi-Gothic /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT GothicBBB-Medium-H /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT GothicBBB-Medium /usr/share/fonts/default/TrueType/ipag-mona.ttf
displayNamedCIDFontTT Ryumin-Light-H /usr/share/fonts/default/TrueType/ipam-mona.ttf
displayNamedCIDFontTT Ryumin-Light /usr/share/fonts/default/TrueType/ipam-mona.ttf
### make default font name to "Ryumin-Light" when converted to PostScript
psFont16 Adobe-Japan1 H Ryumin-Light-H ISO-2022-JP
psFont16 Adobe-Japan1 V Ryumin-Light-V ISO-2022-JP
# use "Gothic-BBB-Medium" if gothic font is required
psNamedFont16 MidashiGo-MB31 H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 MidashiGo-MB31 V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 FutoGoB101-Bold H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 FutoGoB101-Bold V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 HeiseiKakuGo-W5 H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 HeiseiKakuGo-W5 V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 HeiseiKakuGo-W9 H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 HeiseiKakuGo-W9 V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 HeiseiMaruGo-W4 H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 HeiseiMaruGo-W4 V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 MS-Gothic H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 MS-Gothic V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 HG-GothicB H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 HG-GothicB V GothicBBB-Medium-V ISO-2022-JP
psNamedFont16 Kochi-Gothic H GothicBBB-Medium-H ISO-2022-JP
psNamedFont16 Kochi-Gothic V GothicBBB-Medium-V ISO-2022-JP
#----- end Japanese support package

以上、おしまい。

日本語印刷(currentのオフィシャルghostscript環境の場合)

そろそろ何か書かないと大嘘つきになってしまうので、簡単に書いておくことにしよう。

## Slackware-current (2008年1月時点) ghostscript-8.61オフィシャルパッケージを
## インストールした環境で日本語印刷する方法

STEP-1
 以下の説明で日本語フォントはIPAモナーフォントを /usr/share/fonts/IPA-mona
 ディレクトリにインストールしていることを前提とする。

STEP-2
 # cd /usr/share/fonts
# mkdir default
# cd default
# ln -s ../IPA-mona TrueType
 ここでやっていることは、/usr/share/fontsディレクトリに defaultというディレクトリを
 作成し、/usr/share/fonts/defaultにシンボリックリンクTrueType(リンク先 /usr/share/fonts/IPA-mona)を
 作成する。

 (補足)gs -h コマンドを打つと以下のような表示が出る。
     デフォルトサーチパスに /usr/share/fonts/default/TrueType があることわかる。
     つまり、/usr/share/fonts/default/TrueType に日本語フォントを入れておけば gsコマンドが実行
     されたとき自動で日本語フォントを見つけてくれる。
    (見つけてくれるというだけで、文字化けせずに印刷してくれるかどうかは別の話。)

--------
# gs -h
GPL Ghostscript 8.61 (2007-11-21)
Copyright (C) 2007 Artifex Software, Inc. All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
-dNOPAUSE no pause after page | -q `quiet', fewer messages
-g<width>x<height> page size in pixels | -r<res> pixels/inch resolution
-sDEVICE=<devname> select device | -dBATCH exit after last file
-sOutputFile=<file> select output file: - for stdout, |command for pipe,
embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: x11alpha

中略

Search path:
. : /root/.fonts : /usr/share/ghostscript/8.61/lib :
/usr/share/ghostscript/8.61/Resource : /usr/share/ghostscript/fonts :
/usr/share/fonts/default/ghostscript : /usr/share/fonts/default/Type1 :
/usr/share/fonts/default/TrueType : /usr/lib/DPS/outline/base :
/usr/openwin/lib/X11/fonts/Type1 : /usr/openwin/lib/X11/fonts/TrueType :
/usr/share/cups/fonts
For more information, see /usr/share/ghostscript/8.61/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.
--------

STEP-3 Adobe CMapを準備する
 GPL ghostscript-8.61のソースに含まれる Resourceディレクトリを /usr/share/ghostscript/ にコピーする。
 # tar jxvf ghostscript-8.61.tar.bz2
 # cd ghostscript-8.61
 # cp -a Resource /usr/share/ghostscript/

STEP-4 /usr/share/ghostscript/8.61/lib/cidfmapを修正
 cidfmapに以下のエントリを追加(注記:これはIPAモナーフォント用の記述)

----- >8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8 -----
% cidfmap.ja
/ipag << /FileType /TrueType /Path (ipag-mona.ttf) /SubfontID 0 /CSI [ (Japan1) 5 ] >> ;
/ipagp << /FileType /TrueType /Path (ipagp-mona.ttf) /SubfontID 0 /CSI [ (Japan1) 5 ] >> ;
/ipagui << /FileType /TrueType /Path (ipagui-mona.ttf) /SubfontID 0 /CSI [ (Japan1) 5 ] >> ;
/ipam << /FileType /TrueType /Path (ipam-mona.ttf) /SubfontID 0 /CSI [ (Japan1) 5 ] >> ;
/ipamp << /FileType /TrueType /Path (ipamp-mona.ttf) /SubfontID 0 /CSI [ (Japan1) 5 ] >> ;

/Ryumin-Light /ipam ;
/Ryumin-Medium /ipam ;
/GothicBBB-Medium /ipag ;
/ChuGothicBBB-Medium /GothicBBB-Medium ;
/ChuGothicBBB-Medium-Mono /MS-Gothic ;
/FutoGoB101-Bold /GothicBBB-Medium ;
/FutoMinA101-Bold /Ryumin-Light ;
/GothicMB101-Bold /GothicBBB-Medium ;
/GothicMB101-hea /GothicBBB-Medium ;
/GothicMB101-Ult /GothicBBB-Medium ;
/ShinGo-Bold /GothicBBB-Medium ;
/ShinGo-Medium /GothicBBB-Medium ;
/ShinGo-regular /GothicBBB-Medium ;
/MS-Gothic /ipag ;
/MS-PGothic /ipagp ;
/MSPGothic /ipagp ;
/MS-UIGothic /ipagui ;
/MSMincho /ipam ;
/MS-Mincho /ipam ;
/MS-PMincho /ipamp ;
/MSPMincho /ipamp ;
/HeiseiMin-W3 /Ryumin-Light ;
/HeiseiKakuGo-W5 /GothicBBB-Medium ;
/Kochi-Mincho /Ryumin-Light ;
/Kochi-Gothic /GothicBBB-Medium ;
/Adobe-Japan1 /Ryumin-Light ;
/Adobe-Japan2 /Ryumin-Light ;
----- >8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8 -----

STEP-5 gs_res.ps の修正
 /usr/share/ghostscript/8.61/lib/gs_res.ps の修正が必要かもしれない。
 例えばこんなパッチ
----- >8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8 -----
--- gs_res.ps.orig 2008-02-11 12:44:19.000000000 +0900
+++ gs_res.ps 2008-02-11 12:44:11.000000000 +0900
@@ -317,9 +317,9 @@
} if
pssystemparams begin
.default_resource_dir
- /FontResourceDir (Font) .resource_dir_name
+ /FontResourceDir (/usr/share/ghostscript/Resource/CIDFont/) .resource_dir_name
readonly .forcedef % pssys'params is r-o
- /GenericResourceDir () .resource_dir_name
+ /GenericResourceDir (/usr/share/ghostscript/Resource/) .resource_dir_name
readonly .forcedef % pssys'params is r-o
pop % .default_resource_dir
/GenericResourcePathSep
----- >8 ----- >8 ----- >8 ----- >8 ----- >8 ----- >8 -----

ghostscript関連の整備はこれで終了。あとはプリンタを設定すれば印刷できるはず。
プリンタの設定は機種(メーカー)によって変わる可能性があるのでここでは割愛。
ちなみに家の場合、HP製Photosmart-2575,7830をCUPSから設定して問題なく使用中。

実は私はGhostscriptにいくつかパッチをあててソースからビルドしたものを
使ってるので上記の方法で設定しているわけではないが、おおむね上の設定でいけると思う。
別のフォントを使う場合は適宜自分の環境にあわせて読み替えてもらえばよい。
ギャラリー
  • deepl-clip.sh で簡単翻訳 [更新:2025-04-29]
  • Avidemux 2.8.2_20250323_7cf15b3
  • Avidemux 2.8.2_20250323_7cf15b3
  • Avidemux 2.8.x with Qt6 GUI
  • Avidemux 2.8.x with Qt6 GUI
  • MEGAcmd-2.0.0_Linux
  • gcolor3 with Japanese menu and LC_MESSAGES
  • avidemux2 TEST package from the latest git source (on jul.23.2024)
  • fcitx5-mozc-2.29.5135.102.1 (15jw) -- Added "merge-ut-dictionaries"