Re: NSM character type in Bidi algorithm

From: Rick McGowan (
Date: Thu Dec 09 1999 - 14:27:47 EST

Hi Chookij...

> right-to-left (Thai,...)
> left-to-right (Arabic,hebrew)

I think maybe you actually mean L-R in the first and R-L in the second case,
right? Anyway, in this discussion you need to clearly separate characters
from glyphs. You're not displaying the characters directly, you'll need to
do a transformation into glyph space, maybe making some ligatures and
contextual forms. While you're doing that, presumably in some piece of code,
you will probably want to re-arrange the glyphs corresponding to your
non-spacing marks so that they can be properly laid out when you move from
one end of the glyph stream to the other linearly. (The usual manner.)

There is some little "by the way" clause in the book's description of the
bidi algorithm that mentions this, but it's rather obscure, and not explained
in detail.

If you make a function that traverses a "line" from the bidi-resolved text
and you have both the glyphs and characters in storage, you can pretty easily
figure out which glyphs correspond to the non-spacing marks and re-arrange
those during your traversal.

You wrote:
> A,B -> arabic consonant (AR)
> x -> Thai vowel (NSM)
> y -> Thai consonant (L)
> Logical inp: A B y x
> Visual out: B A y x

I think the last line is the correct glyph storage order, presuming "y" to
be a glyph representing a Thai consonant and "x" representing a non-spacing
vowel. I presume that you would render these glyphs as shown above, and the
"x" mark is not really after the "y" but is displayed above it. What you
*don't* want is for the "x" mark to be displayed above the "B".

Your degenerate case of a Thai vowel "y" immediately after the Arabic letter
"B" should result in the "x" being displayed over the "B". I.e.:
        Logical input : A B x
        First pass output : x B A
        Re-ordered visual output: B x A

In other words reading glyphs off left to right, the display has "B" with
"x" above it, then "A".

I hope that is helpful.


This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:56 EDT