metanorma / mn-native-pdf

Development repository for mn2pdf with Metanorma document samples
3 stars 2 forks source link

PDF: experimental feature - vertical layout #713

Open Intelligent2013 opened 2 weeks ago

Intelligent2013 commented 2 weeks ago

Need add support for vertically oriented text for Japanese documents, for instance: image (example from https://www.antennahouse.com/hubfs/xsl-fo-sample/language/writing-mode-1.pdf)

Apache FOP doesn't support a vertical direction property (tb-rl), see https://xmlgraphics.apache.org/fop/2.9/complexscripts.html#writing_mode_property.

Need try to check that Japanese vertical layout can be achieved with two steps:

Intelligent2013 commented 2 weeks ago

turn each character in 90 degrees

In XSL-FO there reference-orientation property, but it relates to the 'area', not for one glyph (https://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html#reference-orientation).

(In AH there is glyph-orientation property https://www.antennahouse.com/hubfs/xsl-fo-sample/character/glyph-orientation-1.pdf?hsLang=en)

There is one more idea - replace each character by SVG with text rotating instruction:

<svg xmlns="http://www.w3.org/2000/svg">
  <text transform="rotate(90)">B</text>
</svg>
Intelligent2013 commented 2 weeks ago

I've tried to replace each character to the SVG with rotated text (one character):

<fo:instream-foreign-object fox:alt-text="{.}">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15">
<text font-size="14pt" transform="rotate(-90,15,0)"><xsl:value-of select="."/></text></svg>
</fo:instream-foreign-object>

and the resulted PDF looks so: (Note: I know that some English letters didn't rotated.)

image Issues:

image

image

So, this approach is waste of time. It generates a bunch of bugs. Emulate glyph properties via SVG markup is very complicated idea.