hebrew.el 4.31 KB
Newer Older
1
;;; hebrew.el --- support for Hebrew -*- coding: iso-2022-7bit; no-byte-compile: t -*-
Karl Heuer's avatar
Karl Heuer committed
2

Glenn Morris's avatar
Glenn Morris committed
3
;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Glenn Morris's avatar
Glenn Morris committed
4
;;   Free Software Foundation, Inc.
Kenichi Handa's avatar
Kenichi Handa committed
5
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
Glenn Morris's avatar
Glenn Morris committed
6
;;   2005, 2006, 2007, 2008, 2009, 2010
Kenichi Handa's avatar
Kenichi Handa committed
7 8
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H14PRO021
Pavel Janík's avatar
Pavel Janík committed
9

Kenichi Handa's avatar
Kenichi Handa committed
10 11 12
;; Copyright (C) 2003
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H13PRO009
Pavel Janík's avatar
Pavel Janík committed
13

Karl Heuer's avatar
Karl Heuer committed
14 15 16 17
;; Keywords: multilingual, Hebrew

;; This file is part of GNU Emacs.

18
;; GNU Emacs is free software: you can redistribute it and/or modify
Karl Heuer's avatar
Karl Heuer committed
19
;; it under the terms of the GNU General Public License as published by
20 21
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Karl Heuer's avatar
Karl Heuer committed
22 23 24 25 26 27 28

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
29
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Karl Heuer's avatar
Karl Heuer committed
30 31 32

;;; Commentary:

Dave Love's avatar
Dave Love committed
33
;; For Hebrew, the character set ISO8859-8 is supported.
Dave Love's avatar
comment  
Dave Love committed
34
;; See http://www.ecma.ch/ecma1/STAND/ECMA-121.HTM.
Dave Love's avatar
Dave Love committed
35
;; Windows-1255 is also supported.
Pavel Janík's avatar
Pavel Janík committed
36

Karl Heuer's avatar
Karl Heuer committed
37 38
;;; Code:

39 40 41 42 43
(define-coding-system 'hebrew-iso-8bit
  "ISO 2022 based 8-bit encoding for Hebrew (MIME:ISO-8859-8)."
  :coding-type 'charset
  :mnemonic ?8
  :charset-list '(iso-8859-8)
Dave Love's avatar
Dave Love committed
44
  :mime-charset 'iso-8859-8)
Karl Heuer's avatar
Karl Heuer committed
45

46
(define-coding-system-alias 'iso-8859-8 'hebrew-iso-8bit)
47

48 49 50 51 52 53 54
;; These are for Explicit and Implicit directionality information, as
;; defined in RFC 1556.  We don't yet support directional information
;; in bidi languages, so these aliases are a lie, especially as far as
;; iso-8859-8-e is concerned.  FIXME.
(define-coding-system-alias 'iso-8859-8-e 'hebrew-iso-8bit)
(define-coding-system-alias 'iso-8859-8-i 'hebrew-iso-8bit)

Karl Heuer's avatar
Karl Heuer committed
55
(set-language-info-alist
Kenichi Handa's avatar
Kenichi Handa committed
56
 "Hebrew" '((charset iso-8859-8)
57
	    (coding-priority hebrew-iso-8bit)
58
	    (coding-system hebrew-iso-8bit windows-1255 cp862)
59
	    (nonascii-translation . iso-8859-8)
60 61
	    (input-method . "hebrew")
	    (unibyte-display . hebrew-iso-8bit)
62
	    (sample-text . "Hebrew	,Hylem(B")
63
	    (documentation . "Bidirectional editing is supported.")))
Karl Heuer's avatar
Karl Heuer committed
64

Dave Love's avatar
Dave Love committed
65 66 67
(set-language-info-alist
 "Windows-1255" '((coding-priority windows-1255)
		  (coding-system windows-1255)
Werner LEMBERG's avatar
Werner LEMBERG committed
68 69
		  (documentation . "\
Support for Windows-1255 encoding, e.g. for Yiddish.
70
Bidirectional editing is supported.")))
Dave Love's avatar
Dave Love committed
71

72 73 74 75 76 77 78 79
(define-coding-system 'windows-1255
  "windows-1255 (Hebrew) encoding (MIME: WINDOWS-1255)"
  :coding-type 'charset
  :mnemonic ?h
  :charset-list '(windows-1255)
  :mime-charset 'windows-1255)
(define-coding-system-alias 'cp1255 'windows-1255)

80
(define-coding-system 'cp862
81
  "DOS codepage 862 (Hebrew)"
82 83 84 85 86 87
  :coding-type 'charset
  :mnemonic ?D
  :charset-list '(cp862)
  :mime-charset 'cp862)
(define-coding-system-alias 'ibm862 'cp862)

Kenichi Handa's avatar
Kenichi Handa committed
88 89 90 91 92 93 94
;; Composition function for hebrew.
(defun hebrew-shape-gstring (gstring)
  (setq gstring (font-shape-gstring gstring))
  (let ((header (lgstring-header gstring))
	(nchars (lgstring-char-len gstring))
	(nglyphs (lgstring-glyph-len gstring))
	(base-width (lglyph-width (lgstring-glyph gstring 0))))
95 96 97
    (while (and (> nglyphs 1)
		(not (lgstring-glyph gstring (1- nglyphs))))
      (setq nglyphs (1- nglyphs)))
Kenichi Handa's avatar
Kenichi Handa committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
    (while (> nglyphs 1)
      (setq nglyphs (1- nglyphs))
      (let* ((glyph (lgstring-glyph gstring nglyphs))
	     (adjust (and glyph (lglyph-adjustment glyph))))
	(if adjust
	    (setq nglyphs 0)
	  (if (>= (lglyph-lbearing glyph) 0)
	      (lglyph-set-adjustment glyph (- base-width) 0 0))))))
  gstring)

(let ((pattern1 "[\u05D0-\u05F2][\u0591-\u05BF\u05C1-\u05C5\u05C7]+")
      (pattern2 "[\u05D0-\u05F2]\u200D[\u0591-\u05BF\u05C1-\u05C5\u05C7]+"))
  (set-char-table-range
   composition-function-table '(#x591 . #x5C7)
   (list (vector pattern2 2 'hebrew-shape-gstring)
	 (vector pattern1 1 'hebrew-shape-gstring)
	 ["[\u0591-\u05C7]" 0 font-shape-gstring]))
  (set-char-table-range
   composition-function-table #x5C0 nil)
  (set-char-table-range
   composition-function-table #x5C6 nil))

Dave Love's avatar
Dave Love committed
120 121
(provide 'hebrew)

122
;; arch-tag: 3ca04f32-3f1e-498e-af46-8267498ba5d9
123
;;; hebrew.el ends here