文字のルビを付けたいと考えています。
XSL-FOではどのような記述になりますか?
- ルビを付ける文字について何か留意点があれば併せて教えてください。
スタック・オーバーフローはプログラマーとプログラミングに熱心な人のためのQ&Aサイトです。すぐ登録できます。
登録してこのコミュニティに参加するXSL 1.1にはルビを表すオブジェクトはありませんので、自力でつけるか、FOプロセッサの拡張機能を使用することになります.
以下は、fo:block中にfo:inline-containerを配置し、その中にルビに対応したfo:blockと本文に対応したfo:blockを並べて表現した例です.
該当部分のFOは次のようになります.ルビのfo:blockのパディングをマイナス値にして位置を調整しています.
<fo:block space-after="1mm">■ モノルビの例</fo:block>
<fo:block line-height="1.6" line-stacking-strategy="max-height">9条
<fo:inline-container alignment-baseline="text-after-edge" start-indent="0mm" end-indent="0mm" text-indent="0mm">
<fo:block
font-size="0.5em" line-height="1.0em" padding-before="-1.0em" text-align-last="center">
<fo:inline>かい</fo:inline>
</fo:block>
<fo:block line-height="1em"
text-align-last="center">壊</fo:block>
</fo:inline-container><fo:inline-container alignment-baseline="text-after-edge" start-indent="0mm" end-indent="0mm" text-indent="0mm">
<fo:block
font-size="0.5em" line-height="1.0em" padding-before="-1.0em" text-align-last="center">
<fo:inline>けん</fo:inline>
</fo:block>
<fo:block line-height="1em"
text-align-last="center">憲</fo:block>
</fo:inline-container>
</fo:block>
代表的なFOプロセッサのAH Formatterの拡張機能である<axf:ruby>
を使用すれば、もっと簡単にルビを生成できます.
<fo:block space-after="1mm">■ モノルビの例(AH Formatter拡張機能)</fo:block>
<fo:block line-height="1.6" line-stacking-strategy="max-height">9条
<axf:ruby>
<axf:ruby-base>壊</axf:ruby-base>
<axf:ruby-text>かい</axf:ruby-text>
</axf:ruby><axf:ruby>
<axf:ruby-base>憲</axf:ruby-base>
<axf:ruby-text>けん</axf:ruby-text>
</axf:ruby>
</fo:block>
ルビにはその他にもグループルビなどの種類があります.以下のW3C技術ノートを参考にして実装方法を考えるのも良い勉強になると思います.
日本語組版処理の要件(日本語版)
3.3 ルビと圏点処理
https://www.w3.org/TR/jlreq/ja/#ruby_and_emphasis_dots
※ なお最初のサンプルはオープンソースのFOPでも試しましたが、fo:inline-containerの処理に不具合があるらしく、正常な組版結果を得ることができませんでした.