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