Commit | Line | Data |
---|---|---|
1bec6fdb | 1 | ;;; indian.el --- Indian languages support -*- coding: iso-2022-7bit; -*- |
4ed46869 | 2 | |
1bec6fdb | 3 | ;; Copyright (C) 1999, 2001 Free Software Foundation, Inc. |
4ed46869 | 4 | |
2fc227cb | 5 | ;; Maintainer: KAWABATA, Taichi <kawabata@m17n.org> |
51896ebc | 6 | ;; Keywords: multilingual, i18n, Indian |
4ed46869 KH |
7 | |
8 | ;; This file is part of GNU Emacs. | |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
e803d6bd KH |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
4ed46869 KH |
24 | |
25 | ;;; Commentary: | |
26 | ||
1bec6fdb RS |
27 | ;; This file defines in-is13194 coding system and relationship between |
28 | ;; indian-glyph character-set and various CDAC fonts. | |
4ed46869 KH |
29 | |
30 | ;;; Code: | |
31 | ||
1bec6fdb RS |
32 | (make-coding-system |
33 | 'in-is13194 2 ?D | |
5ef35063 | 34 | "8-bit encoding for ASCII (MSB=0) and IS13194-Devanagari (MSB=1)." |
1bec6fdb RS |
35 | '(ascii indian-is13194 nil nil |
36 | nil ascii-eol) | |
8805e649 KH |
37 | `((safe-chars . ,(let ((table (make-char-table 'safe-chars nil))) |
38 | (set-char-table-range table 'indian-is13194 t) | |
39 | (dotimes (i 127) | |
40 | (aset table i t) | |
41 | (aset table (decode-char 'ucs (+ #x900 i)) t)) | |
42 | table)) | |
1bec6fdb RS |
43 | (post-read-conversion . in-is13194-post-read-conversion) |
44 | (pre-write-conversion . in-is13194-pre-write-conversion))) | |
45 | ||
8805e649 KH |
46 | (define-coding-system-alias 'devanagari 'in-is13194) |
47 | ||
098d86d5 KH |
48 | (defvar indian-font-foundry 'cdac |
49 | "Font foundry for Indian characters. | |
50 | Currently supported foundries are `cdac' and `akruti'.") | |
51 | ||
52 | (defvar indian-script-language-alist | |
53 | "Alist of Indian scripts vs the corresponding language list and font foundry. | |
54 | Each element has this form: | |
55 | ||
56 | (SCRIPT LANGUAGE-LIST FONT-FOUNDRY) | |
57 | ||
58 | SCRIPT is one of Indian script names. | |
59 | ||
60 | LANGUAGE-LIST is a list of Indian langauge names SCRIPT is used for. | |
61 | The list is in the priority order. | |
62 | ||
63 | FONT-FOUNDRY is a font foundry representing a group of Indian | |
64 | fonts. If the value is nil, the value of `indian-font-foundry' | |
65 | is used." | |
66 | '((devanagari (hindi sanskrit) nil) | |
67 | (bengali (bengali assamese) nil) | |
68 | (gurmukhi (punjabi) nil) | |
69 | (gujarati (gujarati) nil) | |
70 | (oriya (oriya) nil) | |
71 | (tamil (tamil) nil) | |
72 | (telugu (telugu) nil) | |
73 | (kannada (kannada) nil) | |
74 | (malayalam (malayalam) nil))) | |
75 | ||
76 | (defconst indian-font-char-index-table | |
77 | '( ; for which language(s) | |
78 | ;; CDAC fonts | |
79 | (#x0000 . cdac:dv-ttsurekh) ; hindi, etc | |
80 | (#x0100 . cdac:sd-ttsurekh) ; sanskrit | |
81 | (#x0200 . cdac:bn-ttdurga) ; bengali | |
f2029233 KH |
82 | (#x0300 . cdac:tm-ttvalluvar) ; tamil |
83 | (#x0400 . cdac:tl-tthemalatha) ; telugu | |
84 | (#x0500 . cdac:as-ttdurga) ; assamese | |
098d86d5 | 85 | (#x0600 . cdac:or-ttsarala) ; oriya |
f2029233 KH |
86 | (#x0700 . cdac:kn-ttuma) ; kannada |
87 | (#x0800 . cdac:ml-ttkarthika) ; malayalam | |
88 | (#x0900 . cdac:gj-ttavantika) ; gujarati | |
89 | (#x0A00 . cdac:pn-ttamar) ; punjabi | |
098d86d5 KH |
90 | |
91 | ;; AKRUTI fonts | |
92 | (#x0B00 . akruti:dev) ; hindi, etc | |
93 | (#x0C00 . akruti:bng) ; bengali | |
94 | (#x0D00 . akruti:pnj) ; punjabi | |
95 | (#x0E00 . akruti:guj) ; gujarati | |
96 | (#x0F00 . akruti:ori) ; oriya | |
97 | (#x1000 . akruti:tml) ; tamil | |
98 | (#x1100 . akruti:tlg) ; telugu | |
99 | (#x1200 . akruti:knd) ; kannada | |
100 | (#x1300 . akruti:mal) ; malayalam | |
101 | ) | |
102 | "Aliat of indices of `indian-glyph' character vs Indian font identifiers. | |
103 | Each element has this form: (INDEX . FONT-IDENTIFIER) | |
104 | ||
105 | INDEX is an index number of the first character in the charset | |
106 | `indian-glyph' assigned for glyphs in the font specified by | |
107 | FONT-IDENTIFIER. Currently FONT-IDENTIFIERs are defined for CDAC | |
108 | and AKRUTI font groups.") | |
109 | ||
110 | (defun indian-font-char (index font-identifier) | |
111 | "Return character of charset `indian-glyph' made from glyph index INDEX. | |
112 | FONT-IDENTIFIER is an identifier of an Indian font listed in the | |
113 | variable `indian-font-char-index-table'. It specifies which | |
114 | font INDEX is for." | |
115 | (if (or (< index 0) (> index 255)) | |
116 | (error "Invalid glyph index: %d" index)) | |
117 | (let ((start (car (rassq font-identifier indian-font-char-index-table)))) | |
118 | (if (not start) | |
119 | (error "Unknown font identifier: %s" font-identifier)) | |
120 | (setq index (+ start index)) | |
121 | (make-char 'indian-glyph (+ (/ index 96) 32) (+ (% index 96) 32)))) | |
122 | ||
123 | ;; Return a range of characters (cons of min and max character) of the | |
124 | ;; charset `indian-glyph' for displaying SCRIPT in LANGUAGE by a font | |
125 | ;; of FOUNDRY. | |
126 | ||
127 | (defun indian-font-char-range (font-identifier) | |
128 | (cons (indian-font-char 0 font-identifier) | |
129 | (indian-font-char 255 font-identifier))) | |
130 | ||
1bec6fdb RS |
131 | (defvar indian-script-table |
132 | '[ | |
133 | devanagari | |
134 | sanskrit | |
135 | bengali | |
136 | tamil | |
137 | telugu | |
138 | assamese | |
139 | oriya | |
140 | kannada | |
141 | malayalam | |
142 | gujarati | |
143 | punjabi | |
144 | ] | |
145 | "Vector of Indian script names.") | |
146 | ||
147 | (let ((len (length indian-script-table)) | |
148 | (i 0)) | |
149 | (while (< i len) | |
150 | (put (aref indian-script-table i) 'indian-glyph-code-offset (* 256 i)) | |
151 | (setq i (1+ i)))) | |
152 | ||
153 | (defvar indian-default-script 'devanagari | |
154 | "Default script for Indian languages. | |
155 | Each Indian language environment sets this value | |
156 | to one of `indian-script-table' (which see). | |
157 | The default value is `devanagari'.") | |
158 | ||
1bec6fdb RS |
159 | (define-ccl-program ccl-encode-indian-glyph-font |
160 | `(0 | |
161 | ;; Shorten (r1 = (((((r1 - 32) * 96) + r2) - 32) % 256)) | |
162 | (r1 = ((((r1 * 96) + r2) - ,(+ (* 32 96) 32)) % 256)))) | |
163 | ||
164 | (setq font-ccl-encoder-alist | |
165 | (cons (cons "-CDAC" 'ccl-encode-indian-glyph-font) | |
166 | font-ccl-encoder-alist)) | |
167 | ||
098d86d5 KH |
168 | (setq font-ccl-encoder-alist |
169 | (cons (cons "-AKRUTI" 'ccl-encode-indian-glyph-font) | |
170 | font-ccl-encoder-alist)) | |
171 | ||
41da80b1 | 172 | (provide 'indian) |
1bec6fdb | 173 | |
4ed46869 | 174 | ;;; indian.el ends here |