Dienstag, 12. Juli 2011

Vertical writing

VSFilter, pretty much the reference renderer for SSA/ASS, can make use of an obscure Windows feature, often called "@font". When a font name is prefixed with an "@" symbol, Windows switches to a pseudo-vertical writing mode for CJK. Latin characters are written as usual, but CJK characters are rotated and substituted by their vertical forms, if possible. Until now, libass wasn't able to do these substitutions, that especially means punctuation, brackets, parentheses and so on were wrong and and/or wrongly positioned.

With HarfBuzz shaping in place, it is easy to do these substitutions. The OpenType features vert and vkna are responsible for them. vert enables support for vertical writing in general (substitution of brackets, punctuation, et cetera) and vkna enables alternate forms for Kana, if available.


Here's a side-by-side comparison of some random Japanese text. On the left a rendering without substitutions, on the right with both features enabled. The Meiryo font was used.

Montag, 11. Juli 2011

HarfBuzz shaping support

Yeah, it's pretty much working now... after hunting down a few of stupid bugs. libass can now render text without all kinds of OpenType features. Here are a few samples.

Arabic text with diacritics (buggy with FriBidi's shaper).


Connected handwriting (using the Zaner-Bloser Schoolhouse font)


Automatic fractions (using the Calluna font)


Samstag, 9. Juli 2011

Simple Arabic shaping

FriBidi contains a simple Arabic shaper. This shaper is based around the fact that Unicode contains codepoints for presentational forms of many Arabic characters, for traditional reasons. This can be great, as it allows very easy and simple shaping by analyzing the text, without doing any font-specific lookups. However, more advanced shaping features are not possible.

Just now I added support for FriBidi's simple Arabic shaper to libass. The bug about Arabic support contains a test case, and this renders great now.


Work to use a "real" shaper, i.e. HarfBuzz, is already under way, of course. :)

Mittwoch, 6. Juli 2011

libass now supports bidi

After a rather long phase of refactoring and cleaning up libass, I finally started with the BiDi implementation, using FriBidi. This turned out to be easier than expected! Well, at least a buggy first implementation was easy. Let's see where we can go from here.

Here's a sample. Latin text with a bit of Hebrew in it that is rendered right-to-left (RTL).

for example, the Hebrew name Sarah (שרה) is spelled\Nshin (ש) resh (ר) heh (ה) from right to left.


Here's a more complex one. Hebrew text (RTL) with numbers in it (LTR) and brackets, which are mirrored by FriBidi's rather simple shaper (Later, HarfBuzz is going to do mirroring, and a lot more). Note that the dots are incorrectly positioned, that's because I'm forcing the pararaph text direction to LTR at the moment.

דייטשלאנד געהערט צו דער שענגען זאנע (אן גרענעצן) און האט אדאפטירט די איירא (די בשותפותדיקע אייראפעישע וואלוטע) אום 1999...


Directional overrides using special Unicode characters are supported, too.

Hallo wie geht?\N‮Hallo wie geht?

The code will be available in the libass repo soon. There's still some cleanup to do.

Montag, 20. Juni 2011

Sonntag, 5. Juni 2011

Standalone renderer

I just uploaded sources of the standalone renderer with some additional fixes. The archive contains the Git history as well as some sample files.

Freitag, 3. Juni 2011

Finally: Bidi, shaping and line wrapping

It turned out to be more tricky than I imagined, but now it works: a simple, but full text layout engine, that supports bidirectional text with full shaping (where needed) and is capable of wrapping bidirectional text correctly. The code is probably horrible and very inefficient, though.


In the bottom you can see the reference rendering (rendered by a GTK app, i.e. Pango), in the top is my rendering. Note that I have no idea what the Arabic text actually means, I don't know any Arabic language.  I can read the script a bit, but that's all. The text was copy & pasted together from somewhere.

Now it's time to start digging into libass, cleaning up some of the mess and preparing it for inclusion of this functionality.