;; MLYM-RACHANA.flt -- Font Layout Table for Malayalam Rachana font
;; Copyright (C) 2005, 2007  AIST (H15PRO112)
;; See the end for copying conditions.

(font layouter mlym-rachana nil
      (font (nil rachana unicode-bmp)))

;;; <li> MLYM-RACHANA.flt
;;;
;;; For the Rachana Malayalam fonts to draw the traditional Malayalam
;;; script.  This fonts handles virtually all ligatures with the AKHN
;;; feature without character reordering.

;; The first stage is to extract a syllable and re-order characters.
(category
 ;; C: consonant
 ;; H: HALANT
 ;; m: MATRA (Mpre)
 ;; p: MATRA (Mpost)
 ;; t: MATRA (two-part: Mpre+Mpost)
 ;; A: vowel modifier (post) (ANUSVARA and VISARGA)
 ;; V: independent vowel
 ;; E: else (all other independnt characters)
 (0x0D00 0x0D7F	?E)			; else
 (0x0D02 0x0D03	?A)			; ANUSVARA & VISARGA
 (0x0D05 0x0D14	?V)			; independent vowel
 (0x0D15 0x0D39 ?C)			; consonant
 (0x0D3E 0x0D43	?p)			; dependent vowel (Mpost)
 (0x0D46 0x0D48	?m)			; dependent vowel (Mpre)
 (0x0D4A 0x0D4C ?t)			; dependent vowel (two-part)
 (0x0D4D	?H)			; VIRAMA (HALANT)
 (0x0D57	?p)			; dependent vowel (Mpost)
 (0x0D60	?V)			; VOCALIC RR
 (0x0D61	?V)			; VOCALIC LL
 (0x0D7F	?x)			; Internal use
 (0x200C	?N)			; ZERO WIDTH NON-JOINER
 (0x200D	?J)			; ZERO WIDTH JOINER
 )

;; Step 0.  Syllable identification.
(generator
 (0
  (cond
   ;; Halant + ZWNJ -- forced explicit halant.
   ("((CH)*C)HN"
    < | (1 otf:mlym=akhn,psts,haln) 0x0D4D | >)

   ;; Halant + ZWJ -- forced cillaksaram.
   ("(CH)*(CH)J"
    < | (1 otf:mlym=akhn,psts,haln) (2 otf:mlym=haln) | >)

   ;; Pre-consonant vowel is temporarily moved to the leftmost
   ;; position to permit consonant ligature.
   ("((CH)*C)(m)(A?)"
    < | (3 =) (1 otf:mlym=akhn,psts,haln) 0x0D7F (4 =) | >)

   ;; Two-part vowel sign.
   ("((CH)*C)(t)(A?)"
    < | (3 pre) (1 otf:mlym=akhn,psts,haln) 0x0D7F (3 post) (4 =) | >)

   ;; Post-consonant vowel sign and/or vowel modifier.
   ("((CH)*C(pA?|A))"
    < | (1 otf:mlym=akhn,psts,haln) | >)

   ;; No vowel sign.
   ("((CH)*C(H?))"
    < | (1 otf:mlym=akhn,psts,haln) | >)

   ;; A syllable starting with an independent vowel.
   ("(VA?)"
    < | (1 = *) | >)

   ;; Other dedependent character.
   ("[Apmt]" [ = ])

   ;; Other independent character.
   ("." =))
  *)

 ;; Former part of two-part vowel sign.
 (pre
  (cond
   ((0x0D4A) 0x0D46)
   ((0x0D4B) 0x0D47)
   ((0x0D4C) 0x0D46)))

 ;; Latter part of two-part vowel sign.
 (post
  (cond
   ((0x0D4A) 0x0D3E)
   ((0x0D4B) 0x0D3E)
   ((0x0D4C) 0x0D57))))

;; Step 1.  Move Mpre to the left of base consonant(-cluster).
(generator
 (0
  (cond
   (" (m)([^x]*)([^x])x([^ ]*) "
    (2 = *) (1 =) (3 =) (4 = *))
   ("."
    =))
  *))

;; Step 2. Finalise.
(generator
 (0
  (cond
   (" ([^ ]*) " (1 otf:mlym=+))
   ("." =))
  *))

;; Copyright (C) 2005, 2007
;;   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:
