]> code.delx.au - gnu-emacs/blobdiff - lisp/language/devan-util.el
(distclean): Fix a typo (colon was after "clean").
[gnu-emacs] / lisp / language / devan-util.el
index 66afd539cafea871f2728595ba642e208b62f15a..3b7ea9052063e7df8a51bd91659d4a3d1c87b345 100644 (file)
@@ -1,6 +1,10 @@
 ;;; devan-util.el --- Support for composing Devanagari characters
 
-;; Copyright (C) 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 2001, 2002, 2003
+;;   Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Maintainer:  KAWABATA, Taichi <kawabata@m17n.org>
 ;; Keywords: multilingual, Devanagari
 
 (defconst devanagari-composable-pattern
   (concat
-   "\\([\e$,15E\e(B-\e$,15T6@6A\e(B][\e$,15A5B\e(B]?\\)\\|\e$,15C\e(B"
+   "\\([\e$,15E\e(B-\e$,15T6@6A\e(B][\e$,15A5B\e(B]?\\)\\|[\e$,15C6D\e(B]"
    "\\|\\("
    "\\(?:\\(?:[\e$,15U\e(B-\e$,15y68\e(B-\e$,16?\e(B]\e$,16-\e(B\\)?\\(?:[\e$,15U\e(B-\e$,15y68\e(B-\e$,16?\e(B]\e$,16-\e(B\\)?\\(?:[\e$,15U\e(B-\e$,15y68\e(B-\e$,16?\e(B]\e$,16-\e(B\\)?[\e$,15U\e(B-\e$,15y68\e(B-\e$,16?\e(B]\e$,16-\e(B\\)?"
    "[\e$,15U\e(B-\e$,15y68\e(B-\e$,16?\e(B]\\(?:\e$,16-\e(B\\|[\e$,15~\e(B-\e$,16-6B6C\e(B]?[\e$,15B5A\e(B]?\\)?"
    "\\)")
   "Regexp matching a composable sequence of Devanagari characters.")
 
+;;;###autoload
 (defun devanagari-compose-region (from to)
   (interactive "r")
   (save-excursion
@@ -75,6 +80,7 @@
     (devanagari-compose-region (point-min) (point-max))
     (buffer-string)))
 
+;;;###autoload
 (defun devanagari-post-read-conversion (len)
   (save-excursion
     (save-restriction
@@ -410,7 +416,7 @@ PATTERN regexp."
     ("\e$,16-\e(B" . "\e$,4""\e(B")
     ("\e$,16-5p\e(B" . "\e$,4"%\e(B") ;; following "r"
     ;; ("\e$,160\e(B" . "\e$,4 D\e(B")
-    ;; ("\e$,16D\e(B" . "\e$,4 J\e(B")
+    ("\e$,16D\e(B" . "\e$,4 J\e(B")
     ;; ("\e$,16F\e(B" . "")
     ;; ("\e$,16G\e(B" . "")
     ;; ("\e$,16H\e(B" . "")
@@ -537,6 +543,7 @@ preferred rule from the sanskrit fonts."  )
     (,dev-glyph-left-matra . 3) ;; processed by reference point.
     (,dev-glyph-top-matra . 4)
     (,(dev-charseq #xc7 #xc8) . 5)
+    (,(dev-charseq #xc4) . 6)
     (,(dev-charseq #xc6) . 6)
     (,(dev-charseq #xc5) . 7)
     (,dev-glyph-bottom-modifier . 8)))
@@ -563,86 +570,87 @@ preferred rule from the sanskrit fonts."  )
 (defun devanagari-compose-syllable-region (from to)
   "Compose devanagari syllable in region FROM to TO."
   (let ((glyph-str nil) (cons-num 0) glyph-str-list
-        (last-halant nil) (preceding-r nil) (last-modifier nil)
-        (last-char (char-before to)) match-str
-        glyph-block split-pos)
+       (last-halant nil) (preceding-r nil) (last-modifier nil)
+       (last-char (char-before to)) match-str
+       glyph-block split-pos)
     (save-excursion
       (save-restriction
-          ;;; *** char-to-glyph conversion ***
-        ;; Special rule 1. -- Last halant must be preserved.
-        (if (eq last-char ?\e$,16-\e(B)
-            (progn
-              (setq last-halant t)
-              (narrow-to-region from (1- to)))
-          (narrow-to-region from to)
-          ;; note if the last char is modifier.
-          (if (or (eq last-char ?\e$,15A\e(B) (eq last-char ?\e$,15B\e(B))
-              (setq last-modifier t)))
-        (goto-char (point-min))
-        ;; Special rule 2. -- preceding "r halant" must be modifier.
-        (when (looking-at "\e$,15p6-\e(B.")
-          (setq preceding-r t)
-          (goto-char (+ 2 (point))))
-        ;; translate the rest characters into glyphs
-        (while (re-search-forward dev-char-glyph-regexp nil t)
-          (setq match-str (match-string 0))
-          (setq glyph-str
-                (concat glyph-str
-                        (gethash match-str dev-char-glyph-hash)))
-          ;; count the number of consonant-glyhs.
-          (if (string-match devanagari-consonant match-str)
-              (setq cons-num (1+ cons-num))))
-        ;; preceding-r must be attached before the anuswar if exists.
-        (if preceding-r
-            (if last-modifier
-                (setq glyph-str (concat (substring glyph-str 0 -1)
-                                        "\e$,4"'\e(B" (substring glyph-str -1)))
-              (setq glyph-str (concat glyph-str "\e$,4"'\e(B"))))
-        (if last-halant (setq glyph-str (concat glyph-str "\e$,4""\e(B")))
-          ;;; *** glyph-to-glyph conversion ***
-        (when (string-match dev-glyph-glyph-regexp glyph-str)
-          (setq glyph-str
-                (replace-match (gethash (match-string 0 glyph-str)
-                                        dev-glyph-glyph-hash)
-                               nil t glyph-str))
-          (if (and (> cons-num 1)
-                   (string-match dev-glyph-glyph-2-regexp glyph-str))
-              (setq glyph-str
-                    (replace-match (gethash (match-string 0 glyph-str)
-                                            dev-glyph-glyph-2-hash)
-                                   nil t glyph-str))))
-          ;;; *** glyph reordering ***
-        (while (setq split-pos (string-match "\e$,4""\e(B\\|.$" glyph-str))
-          (setq glyph-block (substring glyph-str 0 (1+ split-pos)))
-          (setq glyph-str (substring glyph-str (1+ split-pos)))
-          (setq
-           glyph-block
-           (if (string-match dev-glyph-right-modifier-regexp glyph-block)
-               (sort (string-to-list glyph-block)
-                     (function (lambda (x y)
-                        (< (get-char-code-property x 'composition-order)
-                           (get-char-code-property y 'composition-order)))))
-             (sort (string-to-list glyph-block)
-                   (function (lambda (x y)
-                      (let ((xo (get-char-code-property x 'composition-order))
-                            (yo (get-char-code-property y 'composition-order)))
-                        (if (= xo 2) nil (if (= yo 2) t (< xo yo)))))))))
-          (setq glyph-str-list (nconc glyph-str-list glyph-block)))
-          ;; concatenate and attach reference-points.
-        (setq glyph-str
-              (cdr
-               (apply
-                'nconc
-                (mapcar
-                 (function (lambda (x)
-                   (list
-                    (or (get-char-code-property x 'reference-point)
-                    '(5 . 3) ;; default reference point.
-                     )
-                    x)))
-                 glyph-str-list))))))
+         ;;; *** char-to-glyph conversion ***
+       ;; Special rule 1. -- Last halant must be preserved.
+       (if (eq last-char ?\e$,16-\e(B)
+           (progn
+             (setq last-halant t)
+             (narrow-to-region from (1- to)))
+         (narrow-to-region from to)
+         ;; note if the last char is modifier.
+         (if (or (eq last-char ?\e$,15A\e(B) (eq last-char ?\e$,15B\e(B))
+             (setq last-modifier t)))
+       (goto-char (point-min))
+       ;; Special rule 2. -- preceding "r halant" must be modifier.
+       (when (looking-at "\e$,15p6-\e(B.")
+         (setq preceding-r t)
+         (goto-char (+ 2 (point))))
+       ;; translate the rest characters into glyphs
+       (while (re-search-forward dev-char-glyph-regexp nil t)
+         (setq match-str (match-string 0))
+         (setq glyph-str
+               (concat glyph-str
+                       (gethash match-str dev-char-glyph-hash)))
+         ;; count the number of consonant-glyhs.
+         (if (string-match devanagari-consonant match-str)
+             (setq cons-num (1+ cons-num))))
+       ;; preceding-r must be attached before the anuswar if exists.
+       (if preceding-r
+           (if last-modifier
+               (setq glyph-str (concat (substring glyph-str 0 -1)
+                                       "\e$,4"'\e(B" (substring glyph-str -1)))
+             (setq glyph-str (concat glyph-str "\e$,4"'\e(B"))))
+       (if last-halant (setq glyph-str (concat glyph-str "\e$,4""\e(B")))
+         ;;; *** glyph-to-glyph conversion ***
+       (when (string-match dev-glyph-glyph-regexp glyph-str)
+         (setq glyph-str
+               (replace-match (gethash (match-string 0 glyph-str)
+                                       dev-glyph-glyph-hash)
+                              nil t glyph-str))
+         (if (and (> cons-num 1)
+                  (string-match dev-glyph-glyph-2-regexp glyph-str))
+             (setq glyph-str
+                   (replace-match (gethash (match-string 0 glyph-str)
+                                           dev-glyph-glyph-2-hash)
+                                  nil t glyph-str))))
+         ;;; *** glyph reordering ***
+       (while (setq split-pos (string-match "\e$,4""\e(B\\|.$" glyph-str))
+         (setq glyph-block (substring glyph-str 0 (1+ split-pos)))
+         (setq glyph-str (substring glyph-str (1+ split-pos)))
+         (setq
+          glyph-block
+          (if (string-match dev-glyph-right-modifier-regexp glyph-block)
+              (sort (string-to-list glyph-block)
+                    (function (lambda (x y)
+                       (< (get-char-code-property x 'composition-order)
+                          (get-char-code-property y 'composition-order)))))
+            (sort (string-to-list glyph-block)
+                  (function (lambda (x y)
+                     (let ((xo (get-char-code-property x 'composition-order))
+                           (yo (get-char-code-property y 'composition-order)))
+                       (if (= xo 2) nil (if (= yo 2) t (< xo yo)))))))))
+         (setq glyph-str-list (nconc glyph-str-list glyph-block)))
+         ;; concatenate and attach reference-points.
+       (setq glyph-str
+             (cdr
+              (apply
+               'nconc
+               (mapcar
+                (function (lambda (x)
+                  (list
+                   (or (get-char-code-property x 'reference-point)
+                   '(5 . 3) ;; default reference point.
+                    )
+                   x)))
+                glyph-str-list))))))
       (compose-region from to glyph-str)))
 
 (provide 'devan-util)
 
+;;; arch-tag: 9bc4d6e3-f2b9-4110-886e-ff9b66b7eebc
 ;;; devan-util.el ends here