]> code.delx.au - gnu-emacs/blobdiff - lisp/language/tml-util.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / language / tml-util.el
index b1e56a0ffc12768c0ce79150f7fdb24563d0c9b4..6232a444a9484a55a3d57aec95e38aa151af0d3b 100644 (file)
       (function (lambda (x y) (> (length x) (length y))))))))
 
 
-;;;###autoload
-(defun tamil-composition-function (from to pattern  &optional string)
-  "Compose Tamil characters in REGION, or STRING if specified.
-Assume that the REGION or STRING must fully match the composable 
-PATTERN regexp."
-  (if string (tamil-compose-syllable-string string)
-    (tamil-compose-syllable-region from to))
-  (- to from))
-
-;; Register a function to compose Tamil characters.
-(mapc
- (function (lambda (ucs)
-   (aset composition-function-table (decode-char 'ucs ucs)
-        (list (cons tamil-composable-pattern
-                     'tamil-composition-function)))))
- (nconc '(#x0b82 #x0b83) (tamil-range #x0b85 #x0bb9)))
-
 ;; Notes on conversion steps.
 
 ;; 1. chars to glyphs
@@ -137,7 +120,7 @@ PATTERN regexp."
 
 (defvar tml-char-glyph
   '(;; various signs
-    ;;("\e$,1<"\e(B" . "")
+    ("\e$,1<"\e(B" . "\e$,4)b\e(B")        ;; not good
     ("\e$,1<#\e(B" . "\e$,4*G\e(B")
     ;; Independent Vowels
     ("\e$,1<%\e(B" . "\e$,4*<\e(B")
@@ -336,10 +319,18 @@ PATTERN regexp."
         (narrow-to-region from to)
         (goto-char (point-min))
         ;; char-glyph-conversion
-        (while (re-search-forward tml-char-glyph-regexp nil t)
-          (setq match-str (match-string 0))
-          (setq glyph-str
-                (concat glyph-str (gethash match-str tml-char-glyph-hash))))
+        (while (not (eobp))
+         (if (looking-at tml-char-glyph-regexp)
+             (progn
+               (setq match-str (match-string 0)
+                     glyph-str
+                     (concat glyph-str
+                             (gethash match-str tml-char-glyph-hash)))
+               (goto-char (match-end 0)))
+           (setq glyph-str (concat glyph-str (string (following-char))))
+           (forward-char 1)))
+       (or glyph-str
+           (aset glyph-str 0 (following-char)))
         ;; glyph reordering
         (when (string-match tml-glyph-reorder-key-glyphs glyph-str)
           (if (string-match (car tml-glyph-reordering-regexp-list)
@@ -364,6 +355,25 @@ PATTERN regexp."
                  glyph-str))))
         (compose-region from to glyph-str)))))
 
+;;;###autoload
+(defun tamil-composition-function (pos  &optional string)
+  "Compose Tamil characters after the position POS.
+If STRING is not nil, it is a string, and POS is an index to the string.
+In this case, compose characters after POS of the string."
+  (if string
+      (if auto-compose-current-font
+         (if (eq (string-match "[\e$,1< \e(B-\e$,1=?\e(B]+" pos) pos)
+             (or (font-shape-text 0 (match-end 0) auto-compose-current-font
+                                  string)
+                 pos)))
+    (goto-char pos)
+    (if auto-compose-current-font
+       (if (looking-at "[\e$,1< \e(B-\e$,1=?\e(B]+")
+           (or (font-shape-text pos (match-end 0) auto-compose-current-font))
+         (if (looking-at tamil-composable-pattern)
+             (prog1 (match-end 0)
+               (tamil-compose-syllable-region pos (match-end 0))))))))
+
 (provide 'tml-util)
 
 ;;; arch-tag: 4d1c9737-e7b1-44cf-a040-4f64c50e773e