;; ORYA-OTF.flt -- Font Layout Table for Oriya OpenType font
;; Copyright (C) 2004, 2007  AIST (H15PRO112)
;; See the end for copying conditions.

(font layouter orya-otf nil
      (font (nil nil unicode-bmp :otf=orya=rphf)))

;;; <li> ORYA-OTF.flt
;;;
;;; For Oriya OpenType fonts to draw the Oriya script.

(category
 ;; C: consonant (except for R, B and Y)
 ;; R: consonant RA
 ;; B: consonant (below)
 ;; Y: consonant (post)
 ;; n: NUKTA
 ;; H: HALANT
 ;; m: vowel sign (pre)
 ;; u: vowel sign (above)
 ;; b: vowel sign (below)
 ;; p: vowel sign (post)
 ;; t: vowel sign (two-part)
 ;; A: vowel modifier (above)
 ;; a: vowel modifier (post)
 ;; V: independent vowel
 ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
 ;; J: ZWJ (ZERO WIDTH JOINER)
 ;; X: generic
 ;; Z: internal use
 (0x0B00 0x0B7F ?X)			; generic
 (0x0B00	?Z)			; internal use
 (0x0B01 0x0B03	?a)			; SIGN CANDRABINDU .. VISARGA
 (0x0B05 0x0B14	?V)			; LETTER A .. VOCALIC AU
 (0x0B15 0x0B39	?C)			; LETTER KA .. HA
 (0x0B24	?B)			; LETTER TA
 (0x0B28	?B)			; LETTER NA
 (0x0B2C 0x0B2E	?B)			; LETTER BA .. MA
 (0x0B2F	?Y)			; LETTER YA
 (0x0B30	?R)			; LETTER RA
 (0x0B32 0x0B33	?B)			; LETTER LA
 (0x0B33	?B)			; LETTER LLA
 (0x0B3C	?n)			; SIGN NUKTA
 (0x0B3E	?p)			; VOWEL SIGN AA
 (0x0B3F	?u)			; VOWEL SIGN I
 (0x0B40	?p)			; VOWEL SIGN II
 (0x0B41 0x0B43	?b)			; VOWEL SIGN U .. VOCALIC R
 (0x0B47	?m)			; VOWEL SIGN E
 (0x0B48 0x0B4C ?t)			; VOWEL SIGN AI .. AU
 (0x0B4D	?H)			; SIGN VIRAMA
 (0x0B56	?u)			; AI LENGTH MARK
 (0x0B57	?p)			; AU LENGTH MARK
 (0x0B5C 0x0B5D	?C)			; LETTER RRA .. RHA
 (0x0B5F	?Y)			; LETTER YYA
 (0x0B60 0x0B61	?V)			; LETTER VOCALIC RR .. LL
 (0x0B71	?C)			; LETTER WA
 (0x0B64 0x0B65	?X)			; DANDA .. DOUBLE DANDA
 (0x200C	?N)			; ZWNJ
 (0x200D	?J)			; ZWJ
 )

(generator
 (0
  (cond
   ;; Decompose two-part vowel signs.
   ((0x0B48)
    0x0B47 0x0B56)
   ((0x0B4B)
    0x0B47 0x0B3E)
   ((0x0B4C)
    0x0B47 0x0B57)
   ;; Compose consonant and nukta.
   ((0x0B21 0x0B3C)
    0x0B5C)
   ((0x0B22 0x0B3C)
    0x0B5D)
   ;; Move ZWJ before the consonant.
   ("([CRBY]n?)(J)"
    (2 =) (1 = *))
   ("." =))
  *))

;; Syllable identification and reordering.
;; Do not apply 'rphf' if a syllable begins with a ZWJ.
(generator
 (0
  (cond
   ;; A syllable with a ZWJ and a pre-base vowel sign.
   ;;1  23                    4  5   6   7
   ("(J)(([CRBY]n?H)*[CRBY]n?)(m)(u)?(p)?(a)?"
    < | (1 =) (4 =) (2 pre-below) (5 =) (2 post) (6 =) (7 =) | >)

   ;; A syllable with a ZWJ and a non-pre-base vowel sign.
   ;;1  23                    45      6   7
   ("(J)(([CRBY]n?H)*[CRBY]n?)(([bu])|(p))(a)?"
    < | (1 =) (2 pre-below) (5 =) (2 post) (6 =) (7 =) | >)

   ;; A syllable with a ZWJ and a vowel modifier, but without vowel signs.
   ;;1  23                    4
   ("(J)(([CRBY]n?H)*[CRBY]n?)(a)"
    < | (1 =) (2 pre-below) (2 post) (4 =) | >)

   ;; Add a ZWNJ explicitly when a syllable ends with a halant.
   ;;1  23                    4
   ("(J)(([CRBY]n?H)*[CRBY]n?)(HN?)?"
    < | (1 =) (2 pre-below) (4 = 0x200C) (2 post) | >)

   ;; With a pre-base vowel sign, without a ZWJ.
   ;;1    23                    4  5   6   7
   ("(RH)?(([CRBY]n?H)*[CRBY]n?)(m)(u)?(p)?(a)?"
    < |
    (4 =) (2 pre-below) (5 =) (1 otf:orya=rphf) (2 post) (6 =) (7 =)
    | >)

   ;; With a non-pre-base vowel sign, without a ZWJ.
   ;; 1   23                    45      6   7
   ("(RH)?(([CRBY]n?H)*[CRBY]n?)(([bu])|(p))(a)?"
    < | (2 pre-below) (5 =) (1 otf:orya=rphf) (2 post) (6 =) (7 =) | >)

   ;; With a vowel modifier, without vowel signs and a ZWJ.
   ;;1    23                    4
   ("(RH)?(([CRBY]n?H)*[CRBY]n?)(a)"
    < | (2 pre-below) (1 otf:orya=rphf) (2 post) (4 =) | >)

   ;; Add a ZWNJ explicitly when a syllable ends with a halant.
   ;;1    23                    4
   ("(RH)?(([CRBY]n?H)*[CRBY]n?)(HN?)?"
    < | (2 pre-below) (1 otf:orya=rphf) (4 = 0x200C) (2 post) | >)

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

   ("." =))
  *)

 ;; Move a halant after the base consonant to the end.
 ;; Fill the resulting gap with a special mark.
 ;; Remove post-base parts.
 (pre-below
  (cond
   ("([CRBYnH]*[CYn])H([RBH]+)[YH]+$"
    (1 = *) 0x0B00 (2 = *))
   ("([CRBYnH]*[CYn])(H)([RBH]+)$"
    (1 = *) 0x0B00 (3 = *) (2 =))
   ("([CRBYnH]*[Cn])[YH]*$"
    (1 = *) 0x0B00)
   ("([RB]n?)H([RBH]*)[YH]+$"
    (1 = *) 0x0B00 (2 = *))
   ("([RB]n?)(H)([RBH]*)$"
    (1 = *) 0x0B00 (3 = *) (2 =))
   ("([RBY]n?)[YH]*$"
    (1 = *) 0x0B00)))

 ;; Extract post-base parts and add a halant at the end.
 ;; Produce nothing if there are no post-base parts.
 (post
  (cond
   ("[CRBYnH]*[CRBn]H([YH]+)$"
    (1 = *) 0x0B4D)
   ("Yn?H([YH]+)$"
    (1 = *) 0x0B4D)
   (".+"
    )))
 )

;; Apply language forms to concerning segments.
(generator
 (0
  (cond
   ;; If a syllable contains a ZWNJ, render the final halant explicitly.
   (" ([^Z]+)(Z)([^N]*)(HN)([^ ]*) "
    | (1 otf:orya=nukt,akhn,half,pres+) (2 =) (3 otf:orya=blwf+) (4 = =)
    (5 otf:orya=pstf+) |)

   (" (J?m?)([^Z]+)(Z)([^ ]*) "
    | (1 = *) (2 otf:orya=nukt,akhn,half,pres+) (3 =) (4 otf:orya=blwf,pstf+) |)

   ("." =))
  *))

;; When the number of glyphs between a pre-base vowel sign and the
;; post-base mark is more than one, move the pre-base vowel sign
;; before the final glyph.
(generator
 (0
  (cond
   (" (J)?(m)([^Z]+)([^Z])Z([^N ]*)N?([^ ]*) "
    | (1 =) (3 = *) (2 =) (4 =) (5 = *) (6 = *)|)
   (" ([^Z]+)Z([^N ]*)N?([^ ]*) "
    | (1 = *) (2 = *) (3 = *) |)
   ("." =))
  *))

;; Apply other features.
;; Do not apply 'vatu' and 'blws' if there is a ZWJ.
;; The 'pres' feature is applied again for pre-base vowel sign.
(generator
 (0
  (cond
   (" J([^ ]+) "
    (1 otf:orya=pres,abvs,pstp,haln+abvm,blwm,dist))
   (" ([^ ]+) "
    (1 otf:orya=vatu,pres,abvs,blws,pstp,haln+abvm,blwm,dist))
   ("."
    [ = ]))
  *))

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