pgsql-jp / jpug-doc

PostgreSQL database manual Japanese translation by Japan PostgreSQL Users Group
Other
162 stars 80 forks source link

PDFのビルド #3137

Open tatsuo-ishii opened 2 days ago

tatsuo-ishii commented 2 days ago

重要度

問題点

問題点と言うより質問ですが、PDFのビルド環境ってどうやって作るのでしょうか?普通にmake postgres-A4.pdfとかやると、以下のようなエラーメッセージがたくさん出て、PDFのページ内容は"####..."になっているところ多数になってしまいました。 環境は、Ubuntu 22です。もちろんオリジナル(英文)のPDFは正常にビルドできています。

[WARN] FOUserAgent - Unable to load font file: file:/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc. Reason: java.io.IOException: 'loca' table not found, happens when the font file doesn't contain TrueType outlines (trying to read an OpenType CFF font maybe?)
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] AFMParser - Support for 'StartTrackKern' has not been implemented, yet! Some font data in the AFM file will be ignored.
[WARN] FOUserAgent - Unable to load font file: file:/usr/share/fonts/truetype/fonts-yrsa-rasa/Rasa-Bold.ttf. Reason: java.lang.UnsupportedOperationException: coverage set class table not yet supported
[WARN] FOUserAgent - Unable to load font file: file:/usr/share/fonts/truetype/fonts-yrsa-rasa/Rasa-Regular.ttf. Reason: java.lang.UnsupportedOperationException: coverage set class table not yet supported
[WARN] FOUserAgent - Unable to load font file: file:/usr/share/fonts/truetype/fonts-yrsa-rasa/Rasa-Light.ttf. Reason: java.lang.UnsupportedOperationException: coverage set class table not yet supported
[WARN] FOUserAgent - Unable to load font file: file:/usr/share/fonts/truetype/fonts-yrsa-rasa/Rasa-Medium.ttf. Reason: java.lang.UnsupportedOperationException: coverage set class table not yet supported
[WARN] FOUserAgent - Unable to load font file: file:/usr/share/fonts/truetype/fonts-yrsa-rasa/Rasa-SemiBold.ttf. Reason: java.lang.UnsupportedOperationException: coverage set class table not yet supported
[WARN] TTFFile - Encountered format constraint violation in advanced (typographic) table (AT) in font 'Samanata', ignoring AT data: Reached EOF, file size=129836 offset=160608
[WARN] TTFFile - Encountered format constraint violation in advanced (typographic) table (AT) in font 'Chandas', ignoring AT data: unsupported coverage table format: 152

背景

No response

解決方法

No response

注意点

No response

貢献者として記載可否

記載(貢献者欄に書いてください)

貢献者名

No response

noborus commented 2 days ago

文字が"####"のようになるのは、Apache-FOPはフォントで使用できるフォントがなかったためです。英語に比べて日本語のフォントの埋め込みはややこしいです。

使用候補のフォントはstylesheet-fo.xmlに入れています。

<xsl:param name="title.font.family" select="'YuGothic,Meiryo,MS-PGothic,Hiragino Kaku Gothic ProN,Gen Shin Gothic P,TakaoPGothic'"/>
<xsl:param name="body.font.family" select="'YuMincho,Meiryo,MS-PMincho,Hiragino Mincho ProN,Serif,Gen Shin Gothic P,TakaoPMincho'"/>
<xsl:param name="monospace.font.family" select="'Osaka-mono,MS-Gothic,Gen Shin Gothic Monospace,TakaoGothic'"/>
<xsl:param name="symbol.font.family" select="'Osaka-mono,MS-Gothic,Gen Shin Gothic P,TakaoPGothic'"/>
<xsl:param name="dingbat.font.family" select="'YuGothic,Meiryo,MS-PGothic,Hiragino Kaku Gothic ProN,Gen Shin Gothic P,TakaoPGothic'"/>

Ubuntu 22だと使用できるフォントととして、TakaoPGhothic/MinchoとGen Shin Gothic があります。Gen Shin Gothic はパッケージにないので、https://github.com/pgsql-jp/pgsql-jp.github.io/tree/master/scripts/fonts にコピーしています。こっからダウンロードして、

cp  ~/.fonts/
fc-cache -f -v

でもいけます。

stylesheet-fo.xml にインストールされているフォントを指定すれば変更できますが、OpenType CFF fontが使えなかったりします。 フォントを変えた場合は、日本語のイタリックが見つからなかったりするので、https://github.com/pgsql-jp/jpug-doc/blob/doc_ja_17/doc/src/sgml/fop.xconf で代替の指定が必要になる場合があります。

PDFのビルドは https://github.com/pgsql-jp/pgsql-jp.github.io/blob/master/.github/workflows/main.yml も参考にしてください。

https://github.com/pgsql-jp/jpug-doc/wiki/PDF%E7%89%88%E4%BD%9C%E6%88%90%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA%E8%A8%AD%E5%AE%9A にカスタマイズについて書いています。

tatsuo-ishii commented 8 hours ago

詳しい説明ありがとうございます。追加で質問です。

使用候補のフォントはstylesheet-fo.xmlに入れています。

stylesheet-fo.xmlは当方には存在せず、stylesheet-fo.xlsならありました。

stylesheet-fo.xlsの中に、 <xsl:param name="l10n.gentext.default.language">ja</xsl:param> というのがありますが、これは実際にはどのようにPDFの生成に影響するのでしょうか?SGMLがUTF-8でエンコードされていて、フォントもUTF-8ようのがあれば、特に"ja"対応を意識しなくてもいけるような気がするのですが...

質問の背景としては、本家ではドキュメントのPDFビルドが基本ASCII+LATIN1になっていて、なぜLATIN1以外のUnicode文字が利用できないか、ということが議論されていて、 https://www.postgresql.org/message-id/Zw1rf7vm3FqpItw4%40momjian.us によると、release.sgmlの冒頭コメントに

      We cannot use UTF8 because rendering engines have to
        support the referenced characters.

とあるように、ドキュメントのレンダリングエンジンが(LATIN1を除き)UTF-8をサポートしていないから、とあり、これは違うのではないか、と思ったからです。rendering enginesが何を指すのか明確ではありませんが、斉藤さんの説明を伺って、engineというか、ツールやプログラムの問題ではなく、フォントとフォント設定の問題ではないかという確信が深まりました(間違っていたらご指摘ください)。 もしそうなら、長年UTF-8でドキュメントを作っている本プロジェクトのノウハウを活かして、本家のドキュメントをフルUTF-8対応し、日本語や各国の言語を自由に使えるようにする貢献ができるのではないでしょうか?

noborus commented 2 hours ago

詳しい説明ありがとうございます。追加で質問です。

使用候補のフォントはstylesheet-fo.xmlに入れています。

stylesheet-fo.xmlは当方には存在せず、stylesheet-fo.xlsならありました。

すみません。stylesheet-fo.xslでした。。

stylesheet-fo.xlsの中に、 <xsl:param name="l10n.gentext.default.language">ja</xsl:param> というのがありますが、これは実際にはどのようにPDFの生成に影響するのでしょうか?SGMLがUTF-8でエンコードされていて、フォントもUTF-8ようのがあれば、特に"ja"対応を意識しなくてもいけるような気がするのですが...

これはDocbookの本文以外の対応、 Chapter -> 章、 table of contents -> 目次 等の日本語化をするためです。 前はここで効かせていたのですが、現在はstylesheet-speedup-common.xsl に <xsl:template name="l10n.language">en</xsl:template>が追加されてしまったので、ここをjaにして、こっちが効いてます。

質問の背景としては、本家ではドキュメントのPDFビルドが基本ASCII+LATIN1になっていて、なぜLATIN1以外のUnicode文字が利用できないか、ということが議論されていて、 https://www.postgresql.org/message-id/Zw1rf7vm3FqpItw4%40momjian.us によると、release.sgmlの冒頭コメントに

    We cannot use UTF8 because rendering engines have to
      support the referenced characters.

とあるように、ドキュメントのレンダリングエンジンが(LATIN1を除き)UTF-8をサポートしていないから、とあり、これは違うのではないか、と思ったからです。rendering enginesが何を指すのか明確ではありませんが、斉藤さんの説明を伺って、engineというか、ツールやプログラムの問題ではなく、フォントとフォント設定の問題ではないかという確信が深まりました(間違っていたらご指摘ください)。 もしそうなら、長年UTF-8でドキュメントを作っている本プロジェクトのノウハウを活かして、本家のドキュメントをフルUTF-8対応し、日本語や各国の言語を自由に使えるようにする貢献ができるのではないでしょうか?

SGMLのときにはTex経由でPDFを作る経路があって、これはツールの入れ替えが必要になったのですが、DocbookのXMLの処理系とApache-FOPで処理されるようになってからは、おっしゃるとおりツールの問題はなくフォントと設定の問題です。

ただ、フォントと設定に制限が大きく、複数フォントを指定フォールバックさせようとすると難があったと思うので、複数言語を混ぜるのは難しいように思いました。 Docbookの場合は言語を気にせずイタリックやボールドを指定するのですが、日本語の場合やたぶん特殊な記号もイタリックやボールドの用意はないので、フォールバックして上付き文字になります。 FOPの.foを直接書くならフォントを指定して書いていけば良いのですが、Docbookだとツールが最適なフォントを選ぶことを期待しているというミスマッチがあるのでですが、Apache-FOPはそこまで全然できてないので。

例えば、Apache-FOPはシステムに入っているフォントを使用できるようになっているのですが、フォントを指定しないとぜんぜん探せないので、最初の問題のように####になります。

なのでLATIN1以外の出力をしたくてフォントの指定を追加すると、今度は日本語のフォントが弾き飛ばされることも起こりえるのが現状だと思います。