Sync to HEAD
[bpt/emacs.git] / lisp / language / indian.el
CommitLineData
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
e1915ab3
KH
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)
5e145d59
KH
38 :post-read-conversion 'in-is13194-post-read-conversion
39 :pre-write-conversion 'in-is13194-pre-write-conversion)
e1915ab3
KH
40
41(define-coding-system-alias 'devanagari 'in-is13194-devanagari)
8805e649 42
098d86d5
KH
43(defvar indian-font-foundry 'cdac
44 "Font foundry for Indian characters.
45Currently 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.
49Each element has this form:
50
51 (SCRIPT LANGUAGE-LIST FONT-FOUNDRY)
52
53SCRIPT is one of Indian script names.
54
55LANGUAGE-LIST is a list of Indian langauge names SCRIPT is used for.
56The list is in the priority order.
57
58FONT-FOUNDRY is a font foundry representing a group of Indian
59fonts. If the value is nil, the value of `indian-font-foundry'
60is 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
f2029233
KH
77 (#x0300 . cdac:tm-ttvalluvar) ; tamil
78 (#x0400 . cdac:tl-tthemalatha) ; telugu
79 (#x0500 . cdac:as-ttdurga) ; assamese
098d86d5 80 (#x0600 . cdac:or-ttsarala) ; oriya
f2029233
KH
81 (#x0700 . cdac:kn-ttuma) ; kannada
82 (#x0800 . cdac:ml-ttkarthika) ; malayalam
83 (#x0900 . cdac:gj-ttavantika) ; gujarati
84 (#x0A00 . cdac:pn-ttamar) ; punjabi
098d86d5
KH
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.
98Each element has this form: (INDEX . FONT-IDENTIFIER)
99
100INDEX is an index number of the first character in the charset
101`indian-glyph' assigned for glyphs in the font specified by
102FONT-IDENTIFIER. Currently FONT-IDENTIFIERs are defined for CDAC
103and AKRUTI font groups.")
104
105(defun indian-font-char (index font-identifier)
106 "Return character of charset `indian-glyph' made from glyph index INDEX.
107FONT-IDENTIFIER is an identifier of an Indian font listed in the
108variable `indian-font-char-index-table'. It specifies which
109font 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
1bec6fdb
RS
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.
150Each Indian language environment sets this value
151to one of `indian-script-table' (which see).
152The default value is `devanagari'.")
153
3719c14f
KH
154(defvar indian-composable-pattern
155 (make-char-table nil)
156 "Char table of regexps for composable Indian character sequence.")
098d86d5 157
41da80b1 158(provide 'indian)
1bec6fdb 159
6b61353c 160;;; arch-tag: 83aa8fc7-7ee2-4364-a6e5-498f5e3b8c2f
4ed46869 161;;; indian.el ends here