Bidirectional text and MathML

Ahmed Hindawi pointed out that Digital Editions does not support bidirectional text for ePub, so it is not possible to display documents that use right-to-left writing. Certainly it is a missing feature: IDPF standard for ePub mandates that support. As we internationalize the application, we certainly plan to add that as well as other features that are necessary to display Arabic (ligatures and glyph shaping). I should just point out that the fact that Flash 10 will support that does not automaticaly means that Digital Editions will get it for free, as ePub rendering engine in Digital Editions uses different pipeline for text layout.

Another point that Ahmed made is that there is no support for MathML. In the case of MathML the situation is a bit different from bidirectional text: MathML is not something that IDPF standard mandates for ePub. It is only possible to include MathML “islands” in XHTML if a fallback image is included as well and an ePub viewer is free to display that fallback image instead of rendering MathML. So when including a formula in an ePub document one has to supply either a bitmap (PNG or GIF) or vector graphics (SVG) that reperesents it. Bitmaps for formulas are used on the web quite a bit (e.g. some Wikipedia articles), but their major drawbacks are that they look bad when printed (or font size changes), they don’t reflow when width becomes small and they are unaccessible for blind. Vector graphics is basically how formulas are represesnted in PDF. This does not fully solve the accessibility and reflow problems, but they certainly can be made look as good as MathML. I think that for the time being including vector graphics image for a formula is the best bet, maybe along with a MathML island.

4 Responses to Bidirectional text and MathML

  1. Thank you for your comments on these two issues.For bidirectional text support, do you have any time frames you let us know?For MathML, I was hoping for better news. The fact that IDPF does not require MathML support does not mean of course that ADE should not support it. The idea behind providing the MathML as an island is for viewers that can support MathML, right?Given that mathematics can be supported only via bitmap images or SVG, you are of course right that SVG will certainly be much better. We looked into this but I was told that ADE 1.0 does not even support SVG. Am I mistaken here?If ADE 1.0 supports SVG, can you please provide one or more samples of an epub file that uses SVG to represent mathematical formula? Especially an inline mathematical formula which need a baseline adjustment to fit well within the text (e.g., an inline math formula with subscripts and superscripts)?

  2. Peter Sorotokin says:

    Ahmed,Adobe has a policy that we should not attempt to give out dates for future releases. (In any case, my estimates on when something can be done rarely match reality ;-)You are right that we do not have to wait for IDPF to mandate MathML support before we implement it. Still, even if we did, you as an author would have to provide a meaningful fallback image for the formula, so you’d still have to come up with an image.Digital Editions does support a large subset of SVG, certainly sufficient to draw a mathematical formula.Here is an example that can be embedded inline in an ePub XHTML flow:<svg:svg style=”width:14em;height:2.5em” viewBox=”0 0 110 25″><svg:rect fill=”#FFFF88″ width=”105″ height=”25″/><svg:text font-size=”10″ x=”5″ y=”15″ font-weight=”bold”>Resistance = </svg:text><svg:text font-size=”10″ x=”67″ y=”9″ font-weight=”bold”>Voltage</svg:text><svg:line stroke=”black” x1=”67″ x2=”103″ y1=”12.5″ y2=”12.5″/><svg:text font-size=”10″ x=”67″ y=”22″ font-weight=”bold”>Current</svg:text></svg:svg>Of course, for real-world example you’d probably have to use some tool to export SVG (e.g. Illustrator) and embed the font (so that character metrics are exactly what the layout implies).

  3. Indeed, using SVG, we were able to produce beautifully typeset mathematical equations. An example can be download from the “Full-Text ePUB” link at the URL

  4. Two comments from someone, who is just going to produce it’s first epub book with a lot of Japanese Kanji:Writing SVG text top down (writing-mode=”tb”) does not seem to work as well.There is at least a workaround as font embedding in SVG code works with Digital Editions (I used 1.6): Rotate the text 90 degree clockwise and use a font that has been rotated 90 degree in the other direction (I used the trial version of High Logic’s Font Creator for this). Should work with Arabic and 180 degree rotation as well.