Mavan1 の pdf 出力で文字化け

maven pdf すると、普通に # や四角に文字化けするので、見てみる。フォントがダメっぽい。というわけで、以下の手順で、pdfプラグインにフォントを入れる。

$ cd .maven/cache/maven-pdf-plugin-2.2.1/
$ pushd plugin-resources/fonts/
$ cp /usr/share/fonts/japanese/TrueType/sazanami-gothic.ttf .
$ cp /usr/share/fonts/japanese/TrueType/sazanami-mincho.ttf .
$ java -cp $FOP_PATH/fop-0.20.5.jar org.apache.fop.fonts.apps.TTFReader sazanami-gothic.ttf sazanami-gothic.xml
TTF Reader v1.1.1
Reading sazanami-gothic.ttf...
Number of glyphs in font: 13584
Creating xml font file...
Creating CID encoded metrics
Writing xml font file sazanami-gothic.xml...
This font contains no embedding license restrictions
$ java -cp $FOP_PATH/fop-0.20.5.jar org.apache.fop.fonts.apps.TTFReader sazanami-mincho.ttf sazanami-mincho.xml
TTF Reader v1.1.1
Reading sazanami-mincho.ttf...
Number of glyphs in font: 14679
Creating xml font file...
Creating CID encoded metrics
Writing xml font file sazanami-mincho.xml...
This font contains no embedding license restrictions
$ cd ..
$ vi userconfig.xml
...以下を追加する
<font metrics-file="fonts/sazanami-gothic.xml" embed-file="fonts/sazanami-gothic.ttf" kerning="yes">
<font-triplet name="Gothic" style="normal" weight="normal"/>
<font-triplet name="Gothic" style="normal" weight="bold"/>
<font-triplet name="Gothic" style="italic" weight="normal"/>
<font-triplet name="Gothic" style="italic" weight="bold"/>
</font>
<font metrics-file="fonts/sazanami-mincho.xml" embed-file="fonts/sazanami-mincho.ttf" kerning="yes">
<font-triplet name="Mincho" style="normal" weight="normal"/>
<font-triplet name="Mincho" style="normal" weight="bold"/>
<font-triplet name="Mincho" style="italic" weight="normal"/>
<font-triplet name="Mincho" style="italic" weight="bold"/>
</font>
$ vi fo-styles.xslt
...以下のようにフォントファミリのところにGothicとか追加。
<xsl:attribute name="font-family">Gothic,Mincho,Garamond,serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,monospace</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>
<xsl:attribute name="font-family">Gothic,Mincho,Helvetica,sans-serif</xsl:attribute>

これで、maven pdf とすれば、pdf が出力される。日本語も正しく出ているのだけど、改行がおかしいな・・・。そんなオプションもあるのかな。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です