Subject: Re: bug#20173: 24.4; Rendering misallocates combining marks on ligatures

From: Richard Wordingham <[email-masked]>
Date: Mon, 23 Mar 2015 22:41:07 +0000

On Mon, 23 Mar 2015 17:38:52 +0200
Eli Zaretskii <[email-masked]> wrote:

> > Date: Mon, 23 Mar 2015 01:06:26 +0000
> > From: Richard Wordingham <[email-masked]>

> Is it possible that some rule(s) are missing from the end of
> lisp/language/misc-lang.el?  Could you please take a look and see if
> something needs to be fixed/added in how we set up the compositions
> for Arabic?

There's no relevant problem there.  I demonstrated the bug to myself by
first rendering Tai Tham <NA, TONE-2, SIGN AA> and confirming that
TONE-2 rendered above the first component of the ligature NAA, fromed
from <NA, SIGN AA>.  I then hacked my font so that the glyph for TONE-2
was decomposed into the glyphs for MAI KANG and TONE-2, in that order,
and observing TONE-2 being rendered on the second component of the
ligature.  I then turned to Arabic so that a custom font would not be
needed to demonstrate the bug.

As to what needs fixing in the Arabic section of misc-lang.el:

Clusters containing letters should be limited to letters and marks on
them.  Otherwise, the digits 1, 2, 3 are reversed in a variable name
like بج١٢٣د.  (I'm not sure why the problem doesn't appear with بج١٢٣.)

(set-char-table-range
 composition-function-table
 '(#x600 . #x6FF)
 (list ["[\u0600-\u06FF]+" 0 font-shape-gstring]))

should change to something like

(set-char-table-range
 composition-function-table
 '(#x610 . #x615)
 (list
 ["[\u0610-\u0615\u0621-\u065F\u066E-\u06D3\u06D5-\u06EF\u06FA-\u06FC\u06FF]+"
 0
 font-shape-gstring]))

; Skip punctuation

(set-char-table-range
 composition-function-table
 '(#x621 . #x65F)
 (list 
 ["[\u0610-\u0615\u0621-\u065F\u066E-\u06D3\u06D5-\u06EF\u06FA-\u06FC\u06FF]+"
0 font-shape-gstring]))

; skip digits and punctuation

(set-char-table-range
 composition-function-table
 '(#x66E . #x6D3)
 (list 
 ["[\u0610-\u0615\u0621-\u065F\u066E-\u06D3\u06D5-\u06EF\u06FA-\u06FC\u06FF]+"
 0 font-shape-gstring]))

; skip punctuation

(set-char-table-range
 composition-function-table
 '(#x6D5 . #x6EF)
 (list
 ["[\u0610-\u0615\u0621-\u065F\u066E-\u06D3\u06D5-\u06EF\u06FA-\u06FC\u06FF]+"
  0 font-shape-gstring]))

; Skip digits

(set-char-table-range
 composition-function-table
 '(#x6FA . #x6FC)
 (list 
 ["[\u0610-\u0615\u0621-\u065F\u066E-\u06D3\u06D5-\u06EF\u06FA-\u06FC\u06FF]+"
0 font-shape-gstring]))

; Skip symbols

(set-char-table-range
 composition-function-table
 '(#x6FF . #x6FF)
 (list
 ["[\u0610-\u0615\u0621-\u065F\u066E-\u06D3\u06D5-\u06EF\u06FA-\u06FC\u06FF]+"
0 font-shape-gstring]))

There are more elegant ways of expressing this, which is just as well,
for there are also blocks Arabic Supplement (U+0750 to U+077F) and
Arabic Extended-A (U+08A0 to U+08FF).  Being an international script,
the Arabic script has a lot of letters, just like the Latin script.

Richard.