Merge from emacs--devo--0
[bpt/emacs.git] / lisp / language / indian.el
1 ;;; indian.el --- Indian languages support -*- coding: iso-2022-7bit; -*-
2
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
7
8 ;; Maintainer: KAWABATA, Taichi <kawabata@m17n.org>
9 ;; Keywords: multilingual, i18n, Indian
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
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
27
28 ;;; Commentary:
29
30 ;; This file defines in-is13194 coding system and relationship between
31 ;; indian-glyph character-set and various CDAC fonts.
32
33 ;;; Code:
34
35 (define-coding-system 'in-is13194-devanagari
36 "8-bit encoding for ASCII (MSB=0) and IS13194-Devanagari (MSB=1)."
37 :coding-type 'iso-2022
38 :mnemonic ?D
39 :designation [ascii indian-is13194 nil nil]
40 :charset-list '(ascii indian-is13194)
41 :post-read-conversion 'in-is13194-post-read-conversion
42 :pre-write-conversion 'in-is13194-pre-write-conversion)
43
44 (define-coding-system-alias 'devanagari 'in-is13194-devanagari)
45
46 (defvar indian-font-foundry 'cdac
47 "Font foundry for Indian characters.
48 Currently supported foundries are `cdac' and `akruti'.")
49
50 (defvar indian-script-language-alist
51 '((devanagari (hindi sanskrit) nil)
52 (bengali (bengali assamese) nil)
53 (gurmukhi (punjabi) nil)
54 (gujarati (gujarati) nil)
55 (oriya (oriya) nil)
56 (tamil (tamil) nil)
57 (telugu (telugu) nil)
58 (kannada (kannada) nil)
59 (malayalam (malayalam) nil))
60 "Alist of Indian scripts vs the corresponding language list and font foundry.
61 Each element has this form:
62
63 (SCRIPT LANGUAGE-LIST FONT-FOUNDRY)
64
65 SCRIPT is one of Indian script names.
66
67 LANGUAGE-LIST is a list of Indian langauge names SCRIPT is used for.
68 The list is in the priority order.
69
70 FONT-FOUNDRY is a font foundry representing a group of Indian
71 fonts. If the value is nil, the value of `indian-font-foundry'
72 is used.")
73
74 (defconst indian-font-char-index-table
75 '( ; for which language(s)
76 ;; CDAC fonts
77 (#x0000 . cdac:dv-ttsurekh) ; hindi, etc
78 (#x0100 . cdac:sd-ttsurekh) ; sanskrit
79 (#x0200 . cdac:bn-ttdurga) ; bengali
80 (#x0300 . cdac:tm-ttvalluvar) ; tamil
81 (#x0400 . cdac:tl-tthemalatha) ; telugu
82 (#x0500 . cdac:as-ttdurga) ; assamese
83 (#x0600 . cdac:or-ttsarala) ; oriya
84 (#x0700 . cdac:kn-ttuma) ; kannada
85 (#x0800 . cdac:ml-ttkarthika) ; malayalam
86 (#x0900 . cdac:gj-ttavantika) ; gujarati
87 (#x0A00 . cdac:pn-ttamar) ; punjabi
88
89 ;; AKRUTI fonts
90 (#x0B00 . akruti:dev) ; hindi, etc
91 (#x0C00 . akruti:bng) ; bengali
92 (#x0D00 . akruti:pnj) ; punjabi
93 (#x0E00 . akruti:guj) ; gujarati
94 (#x0F00 . akruti:ori) ; oriya
95 (#x1000 . akruti:tml) ; tamil
96 (#x1100 . akruti:tlg) ; telugu
97 (#x1200 . akruti:knd) ; kannada
98 (#x1300 . akruti:mal) ; malayalam
99 )
100 "Alist of indices of `indian-glyph' character vs Indian font identifiers.
101 Each element has this form: (INDEX . FONT-IDENTIFIER)
102
103 INDEX is an index number of the first character in the charset
104 `indian-glyph' assigned for glyphs in the font specified by
105 FONT-IDENTIFIER. Currently FONT-IDENTIFIERs are defined for CDAC
106 and AKRUTI font groups.")
107
108 (defun indian-font-char (index font-identifier)
109 "Return character of charset `indian-glyph' made from glyph index INDEX.
110 FONT-IDENTIFIER is an identifier of an Indian font listed in the
111 variable `indian-font-char-index-table'. It specifies which
112 font INDEX is for."
113 (if (or (< index 0) (> index 255))
114 (error "Invalid glyph index: %d" index))
115 (let ((start (car (rassq font-identifier indian-font-char-index-table))))
116 (if (not start)
117 (error "Unknown font identifier: %s" font-identifier))
118 (setq index (+ start index))
119 (make-char 'indian-glyph (+ (/ index 96) 32) (+ (% index 96) 32))))
120
121 ;; Return a range of characters (cons of min and max character) of the
122 ;; charset `indian-glyph' for displaying SCRIPT in LANGUAGE by a font
123 ;; of FOUNDRY.
124
125 (defun indian-font-char-range (font-identifier)
126 (cons (indian-font-char 0 font-identifier)
127 (indian-font-char 255 font-identifier)))
128
129 (defvar indian-script-table
130 '[
131 devanagari
132 sanskrit
133 bengali
134 tamil
135 telugu
136 assamese
137 oriya
138 kannada
139 malayalam
140 gujarati
141 punjabi
142 ]
143 "Vector of Indian script names.")
144
145 (let ((len (length indian-script-table))
146 (i 0))
147 (while (< i len)
148 (put (aref indian-script-table i) 'indian-glyph-code-offset (* 256 i))
149 (setq i (1+ i))))
150
151 (defvar indian-default-script 'devanagari
152 "Default script for Indian languages.
153 Each Indian language environment sets this value
154 to one of `indian-script-table' (which see).
155 The default value is `devanagari'.")
156
157 (defvar indian-composable-pattern
158 (make-char-table nil)
159 "Char table of regexps for composable Indian character sequence.")
160
161 (provide 'indian)
162
163 ;;; arch-tag: 83aa8fc7-7ee2-4364-a6e5-498f5e3b8c2f
164 ;;; indian.el ends here