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