;; HEBR-OTF.flt -- Font Layout Table for Hebrew OpenType fonts
;; Copyright (C) 2010 AIST (H15PRO112)
;; Copyright (C) 2015  K. Handa <handa@gnu.org>
;; See the end for copying conditions.

(font layouter hebr-otf nil
      (font (nil nil unicode-bmp :otf=hebr)))

;;; <li> HEBR-OTF.flt
;;;
;;; For Hebrew OpenType fonts to draw the Hebrew script.

(category
 (0x0590 0x05FF	?X)			; generic
 (0x0591 0x05AF ?m)			; cantillation marks
 (0x05B0 0x05BB	?v)			; vowels
 (0x05BC	?d)			; dagesh
 (0x05BD	?P)			; meteg
 (0x05BF	?p)			; rafe
 (0x05C1 0x05C2 ?s)			; shin/sin dot
 (0x05C4 0x05C5 ?p)			; upper/lower dot
 (0x05C7	?v)			; qamats qatan
 (0x05D0 0x05EA	?C)			; consonants
 (0x05E9	?S)			; shin
 (0x05F0 0x05F2	?C)			; yiddish ligatures

 (0xFB1D 0xFB4F	?X)			; generic
 (0xFB1E	?p)			; judeo-spanish varika

 (0x034F	?G)			; COMBINING GRAPHEME JOINER
 (0x200C	?N)			; ZWNJ
 (0x200D	?J)			; ZWJ
 (0x25CC	?X)			; DOTTED CIRCLE
 (mark		?M)			; OTF feature "mark" is applied.
 (mkmk		?k)			; OTF feature "mkmk" is applied.
 )

;; Order the marks roughly according to "SBL Hebrew manual"
;; <http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf>.
(generator
 (0
  (cond
   ("((s)|(d)|(p)|(v)|([mP]))+"
    (2 =) (3 =) (4 =) (5 =) (6 =))
   
   ("." =))
  *))

(generator
 (0
  (cond
   ;; Special case SHIN first: Allow the SHIN dots (?s).
   ("S[sdGJmPpv]+"
    | < :otf=hebr > |)

   ;; The general case without the SHIN dots (?s).
   ("C[dGJmPpv]+"
    | < :otf=hebr > |)

   ;; Put stand-alone diacritics on a DOTTED CIRCLE.
   ("[dmPpsv]+"
    (cond
     ((font-facility 0x25CC) < 0x25CC = >)
     ("." [ = ])))

   ("." =))
  *))

;; Put marks without the mark/mkmk feature before the base character.
;; Glyph clusters are surrounded by the mnemonic " " added by the
;; previous generator.
(generator
 (0
  (cond
   ;; Precomposed.
   (" ([^ ]) " (1 =))
   ;; Feature "mark" and/or "mkmk" are applied.
   (" ([^ ]M[Mk]*) " (1 = =))
   ;; No OTF feature is applied.  Hope the font metric is designed
   ;; properly so that drawing the combined marks first then the base
   ;; character yields correct result.
   (" ([^ ])([^ ]+) " [ (2 = *) (1 =) ])
   ("." =))
  *))

;; Copyright (C) 2010
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H15PRO112
;; Copyright (C) 2015  K. Handa <handa@gnu.org>

;; This file is part of the m17n database; a sub-part of the m17n
;; library.

;; The m17n library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public License
;; as published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.

;; The m17n library 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
;; Lesser General Public License for more details.

;; You should have received a copy of the GNU Lesser General Public
;; License along with the m17n library; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;; Local Variables:
;; mode: emacs-lisp
;; End:
