;;; <li> GUJR-OTF.flt
;;;
;;; For Gujarati OpenType fonts to draw the Gujarati script.
-;;; Tested with padmaa-Medium-1.5.ttf <http://www.indictrans.org/>
(font layouter gujr-otf nil
(font (nil nil unicode-bmp :otf=gujr=rphf)))
(category
- ;; C: general consonant
- ;; R: RA
- ;; V: independent vowel
+ ;; C: consonant (except for RA)
+ ;; R: consonant RA
+ ;; n: NUKTA
;; H: HALANT
- ;; m: MATRA (pre)
- ;; u: MATRA (above)
- ;; b: MATRA (below)
- ;; p: MATRA (post)
+ ;; m: vowel sign (pre)
+ ;; u: vowel sign (above)
+ ;; b: vowel sign (below)
+ ;; p: vowel sign (post)
;; A: vowel modifier (above)
;; a: vowel modifier (post)
- ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
- ;; J: ZWJ (ZERO WIDTH JOINER)
- ;; E: ELSE
- ;;
- (0x200C ?N) ; ZWNJ
- (0x200D ?J) ; ZWJ
- (0x0964 ?E) ; DANDA
- (0x0965 ?E) ; DOUBLE DANDA
- (0x0A80 0x0AFF ?E) ; ELSE
- (0x0A81 ?A) ; SIGN CANDRABINDU
- (0x0A82 ?A) ; SIGN ANUSVARA
+ ;; V: independent vowel
+ ;; N: ZWNJ
+ ;; J: ZWJ
+ ;; X: generic
+ (0x0A80 0x0AFF ?X) ; generic
+ (0x0A81 0x0A82 ?A) ; SIGN CANDRABINDU .. ANUSVARA
(0x0A83 ?a) ; SIGN VISARGA
- (0x0A85 0x0A94 ?V) ; LETTER AA .. LETTER AU
- (0x0A95 0x0AB9 ?C) ; LETTER KA .. LETTER HA
+ (0x0A85 0x0A94 ?V) ; LETTER AA .. AU
+ (0x0A95 0x0AB9 ?C) ; LETTER KA .. HA
(0x0AB0 ?R) ; LETTER RA
(0x0ABC ?n) ; SIGN NUKTA
- (0x0ABE ?p) ; VOWEL SIGN AA (post)
- (0x0ABF ?m) ; VOWEL SIGN I (pre)
- (0x0AC0 ?p) ; VOWEL SIGN II (post)
- (0x0AC1 0x0AC4 ?b) ; VOWEL SIGN U, UU, R, RR (below)
- (0x0AC5 0x0AC8 ?u) ; VOWEL SIGN CANDRA E, E, AI (above)
- (0x0AC9 0x0ACC ?p) ; VOWEL SIGN CANDRA O, O, AU (post)
- (0x0ACD ?H) ; SIGN VIRAMA (HALANT)
- (0x0AE0 0x0AE1 ?V) ; LETTER VOCALIC RR, LL
- (0x0AE2 0x0AE3 ?b) ; VOWEL SIGN VOCALIC RR, LL (below)
- (0x0AFF ?X) ; internal use
+ (0x0ABE ?p) ; VOWEL SIGN AA
+ (0x0ABF ?m) ; VOWEL SIGN I
+ (0x0AC0 ?p) ; VOWEL SIGN II
+ (0x0AC1 0x0AC4 ?b) ; VOWEL SIGN U .. VOCALIC RR
+ (0x0AC5 0x0AC8 ?u) ; VOWEL SIGN CANDRA E .. AI
+ (0x0AC9 0x0ACC ?p) ; VOWEL SIGN CANDRA O .. AU
+ (0x0ACD ?H) ; SIGN VIRAMA
+ (0x0AE0 0x0AE1 ?V) ; LETTER VOCALIC RR .. VOCALIC LL
+ (0x0AE2 0x0AE3 ?b) ; VOWEL SIGN VOCALIC L .. VOCALIC LL
+ (0x0964 0x0965 ?X) ; DANDA .. DOUBLE DANDA
+ (0x200C ?N) ; ZWNJ
+ (0x200D ?J) ; ZWJ
)
-;; Step 1 : Syllable identification, Reph and base consonant movements.
+;; Reordering
(generator
(0
(cond
- ;; A syllable ending with a vowel sign and/or a vowel modifier.
- ("(([CR]n?H)*[CR]n?)([mubp][Aa]?|[Aa])"
- < | (1 move-reph-vattu) (3 = *) | >)
-
- ;; Forced Halant or half form.
- ("(([CR]n?H)*[CR]n?)(H[NJ])"
- < | (1 move-reph-vattu) (3 = =) | >)
-
- ;; A syllable without a vowel sign nor a vowel modifier.
- ("([CR]n?H)*[CR]n?H?"
- < | move-reph-vattu | >)
+ ;; A syllable containing a vowel sign.
+ ;;1 23 45 6 7
+ ("(RH)?(([CR]n?H)*[CR]n?)((m)|([bup]))(A?a?)"
+ < | (5 =) (2 move-h) (6 =) (1 otf:gujr=rphf+) (7 = *) | >)
+
+ ;; A syllable without vowel signs but with a vowel modifier.
+ ;;1 23 4
+ ("(RH)?(([CR]n?H)*[CR]n?)([Aa])"
+ < | (2 move-h) (1 otf:gujr=rphf+) (4 =) | >)
+
+ ;; Forced half form. Do not move halant.
+ ;;1 23
+ ("(RH)?(([CR]n?H)+)J"
+ < | (2 = *) (1 otf:gujr=rphf+) | >)
+
+ ;; When a syllable ends with a halant, add a ZWNJ explicitly.
+ ;;1 23 4
+ ("(RH)?(([CR]n?H)*[CR]n?)(H)?N?"
+ < | (2 move-h) (1 otf:gujr=rphf+) (4 = 0x200C) | >)
;; A syllable starting with an independent vowel.
- ("V[Aa]?"
- < | = * | >)
+ ("VA?a?"
+ < | = * | >)
("." =))
*)
- ;; Move the leading RH and the Halant on the base consonant to
- ;; appropriate positions.
- ;; 0x0AFF indicates the destination of below-, above-, post Matras.
- (move-reph-vattu
+ (move-h
(cond
- ;; Ending with Halnt. Immitate a forced Halant form.
- ("(.*)(H)$"
- (1 move-reph-vattu) (2 =) 0x200C)
-
- ;; Both Reph and Vattu.
- ;;1 23 4 5
- ("(RH)(([CR]n?H)*[CR]n?)(H)(R)$"
- (2 = *) (5 =) (4 =) 0x0AFF (1 = =))
+ ("([CRnH]+)(H)(R)$"
+ (1 = *) (3 =) (2 =))
+ (".+"
+ = *))))
- ;; A special case of above.
- ("(RH)(R)$"
- (2 =) 0x0AFF (1 = =))
-
- ;; Reph but no Vattu.
- ("(RH)(([CR]n?H)*Cn?)$"
- (2 = *) 0x0AFF (1 = =))
-
- ;; No Reph but Vattu.
- ("(Cn?(H[CR]n?)*)(H)(R)$"
- (1 = *) (4 =) (3 =) 0x0AFF)
-
- ;; Neither Reph nor Vattu.
- (".*"
- = * 0x0AFF))))
-
-;; Step 2 : Matra movements and OTF forms.
+;; If a syllable ends with a halant and a ZWNJ, render the final
+;; halant explicitly. Do not apply 'blwf' to the initial RA.
(generator
(0
(cond
- ;; 1 2 3 4 5 6
- (" (RH)?([^X ]*)X(RH)?(m)?([bup])?([Aa])? "
- |
- (4 =)
- (1 otf:gujr=~rphf,~blwf,*)
- (2 otf:gujr=~rphf,*)
- (5 =)
- (3 otf:gujr=rphf)
- (6 =)
- |)
-
- (" (RH)?([^X ]*)X(RH)?(HJ) "
- |
- (1 = =)
- (2 otf:gujr=~rphf)
- (3 otf:gujr=rphf)
- (4 = =)
- |)
-
- (" (RH)?([^X ]*)X(RH)?(H)N "
- |
- (1 otf:gujr=~rphf,~blwf,*)
- (2 otf:gujr=~rphf,*)
- (3 otf:gujr=rphf)
- (4 =)
- |)
-
+ (" (R)([^N]*)(H)N "
+ | (1 =) (2 gsub1) (3 =) |)
+ (" (m?R)([^ ]*) "
+ | (1 = *) (2 gsub1) (3 = *) |)
+ (" ([^N]+)(H)N "
+ | (1 gsub1) (2 =) |)
+ (" ([^ ]+) "
+ | (1 gsub1) |)
("." =))
- *))
+ *)
+
+ (gsub1
+ otf:gujr=nukt,akhn,blwf,half,vatu,pres+))
-;; Step 3 : OTF substitutions and positionings.
+;; Apply other features. The 'pres' feature is applied again for
+;; pre-base vowel sign.
(generator
(0
(cond
- (" (.*)J "
- (1 otf:gujr=~rphf,~blwf,*))
- (" ([^ ]*) "
- (1 otf:gujr=~rphf,~blwf,~half,~haln,*))
+ (" ([^ ]+) "
+ (1 otf:gujr=pres,abvs,blws,psts,haln+abvm,blwm,dist))
("."
- [ otf:gujr=+ ]))
+ [ = ]))
*))
;; Local Variables: