Subject: bug#5080: indic text is not displayed correctly in emacs shell

From: Kenichi Handa <[email-masked]>
Date: Fri, 04 Dec 2009 21:52:38 +0900

In article <[email-masked]>, Kenichi Handa <[email-masked]> writes:

> In article <[email-masked]>, Praveen A <[email-masked]> writes:
> > (1) font file name (if possible, with the version number)
> > 
> > lohit_ml.ttf (ttf-malayalam-fonts 1:0.5.6)
> > http://ftp.de.debian.org/debian/pool/main/t/ttf-indic-fonts/ttf-indic-fonts_0.5.6.tar.gz
> > 
> > (2) problematic character sequence
> > 
> > 0x0D23 0x0D4D 0x200D
> > 
> > (ണ ് ‍)

> Thank you for the data.  I downloaded lohit_ml.ttf and
> confirmed the bug.  I'll check what is wrong.

Please put the attached file (MLYM-OTF.flt) under ~/.m17n.d/
and try again.  If it works, move that file to
/usr/share/m17n.

---
Kenichi Handa
[email-masked]

--- MLYM-OTF.flt ---
;; MLYM-OTF.flt -- Font Layout Table for Malayalam OpenType font
;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009  AIST (H15PRO112)
;; See the end for copying conditions.

(font layouter mlym-otf nil
      (font (nil nil unicode-bmp :otf=mlym=akhn)))

;;; <li> MLYM-OTF.flt
;;;
;;; For Malayalam OpenType fonts to draw the reformed Malayalam script.

;; Tested with the following fonts.  All of these fonts require Halant
;; movement for syllable-final YA and VA, but not for RA and LA.

;; AnjaliOldLipi.ttf
;; Dyuthi3.ttf
;; Kalyani121.ttf
;; Meera_04.ttf
;; Rachana_04.ttf
;; RaghuMalayalamSans2.ttf
;; suruma2.ttf

(category
 ;; C: ordinary consonants (except P)
 ;; P: consonants that have a post form
 ;; H: HALANT
 ;; m: vowel sign (pre)
 ;; b: vowel sign (below)
 ;; p: vowel sign (post)
 ;; A: vowel modifier (post)
 ;; V: independent vowel
 ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
 ;; J: ZWJ (ZERO WIDTH JOINER)
 ;; Z: internal use
 ;; X: generic
 (0x0D00 0x0D7F	?X)			; generic
 (0x0D00        ?Z)			; internal use
 (0x0D02 0x0D03	?A)			; SIGN ANUSVARA .. VISARGA
 (0x0D05 0x0D14	?V)			; LETTER A .. AU
 (0x0D15 0x0D39 ?C)			; LETTER KA .. HA
 (0x0D2F	?P)			; LETTER YA
 (0x0D35	?P)			; LETTER VA
 (0x0D3E 0x0D44	?p)			; VOWEL SIGN AA .. VOCALIC RR
 (0x0D46 0x0D48	?m)			; VOWEL SIGN E .. AI
 (0x0D4D	?H)			; SIGN VIRAMA
 (0x0D57	?p)			; AU LENGTH MARK
 (0x0D60 0x0D61	?V)			; LETTER VOCALIC RR .. VOCALIC LL
 (0x0D62 0x0D63 ?b)			; VOWEL SIGN VOCALIC L .. LL
 (0x0964 0x0965	?X)			; DANDA .. DOUBLE DANDA
 (0x200C	?N)			; ZWNJ
 (0x200D	?J)			; ZWJ
 )

;; Stage 0
;; Decompose two-part vowels.
(generator
 (0
  (cond
   ((0x0D4A)
    0x0D46 0x0D3E)
   ((0x0D4B)
    0x0D47 0x0D3E)
   ((0x0D4C)
    0x0D46 0x0D57)
   ("." =))
  *))

;; Stage 1
;; Syllable identification and reordering.  
;; Put the mark Z after the base consonant.
(generator
 (0
  (cond
   ;; A syllable with a left vowel sign.
   ;;1    2        3  4
   ("([CP](H[CP])*)(m)(p?A?)"
    < | (3 =) (1 move-h) (4 = *) | >)

   ;; A syllable with a right vowel sign, a below vowel sign
   ;; and/or a vowel modifier.
   ;;1    2        3
   ("([CP](H[CP])*)(bA?|pA?|A)"
    < | (1 move-h) (3 = *) | >)

   ;; Forced chillu form.
   ;;1    2        3
   ("([CP](H[CP])*)(HJ)"
    < | (1 move-h) (3 = =) | >)

   ;; A syllable with no vowel signs/modifiers, optionally followed by
   ;; an H or an HN.
   ;;1    2        3
   ("([CP](H[CP])*)(H|HN)?"
    < | (1 move-h) (3 0x0D4D) | >)

   ;; Starting with an independent vowel.
   ("VA?"
    < | (0 = *) | >)

   ("." =))
  *)

 ;; Move the halant that follows the base consonant to the end.
 (move-h
  (cond
   ;; All consonants are P's.
   ("(P)(H)([PH]*)$"
    (1 =) 0x0D00 (3 = *) (2 =))

   ;; One or more Non-P consonants.
   ("([CPH]*C)(H)([PH]+)$"
    (1 = *) 0x0D00 (3 = *) (2 =))

   ;; Otherwise, final consonant is not P.  No need to move H.
   (".+"
    = * 0x0D00)))
 )

;; Stage 2
;; Apply GSUB features.
(generator
 (0
  (cond
   ;; The tested fonts make LA's below form with 1. 'half' + 'blws',
   ;; 2. 'half' + 'pres' or 3. 'akhn'.
   ;; 1   2       3  4
   (" (m)?([CPH]*)(Z)([PHbpAJ]*) "
    | (1 =) (2 otf:mlym=akhn,half,pstf,pres,abvs,blws+) (3 =)
    (4 otf:mlym=pstf+) |)

   ("." =))
  *))

;; Stage 3
;; Second reordering.  If there are glyphs before the base, move left
;; vowel sign to the left of the base.
(generator
 (0
  (cond
   ;; 1   2       3      4
   (" (m)?([^Z ]*)([^Z])Z([^ ]*) "
    | (2 = *) (1 =) (3 =) (4 = *) |)

   ("." =))
  *))

;; Stage 4
;; Apply remaining GSUB and GPOS features to all syllables.  To get
;; correct Y.YA and V.VA conjunctions, we must apply 'psts' to the
;; entire syllable.
(generator
 (0
  (cond
   (" ([^ ]+) "
    (1 otf:mlym=akhn,psts,haln+abvm,blwm,dist))
   ("."
    [ = ]))
  *))

;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H15PRO112

;; This file is part of the m17n database; a sub-part of the m17n
;; library.

;; The m17n library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public License
;; as published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.

;; The m17n library is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Lesser General Public License for more details.

;; You should have received a copy of the GNU Lesser General Public
;; License along with the m17n library; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;; Local Variables:
;; mode: emacs-lisp
;; End: