% \iffalse meta-comment
%
% Copyright (C) 2011,2012,2013 Zvi Gilboa (zgilboa@virginia.edu)
% 
% This file is part of the `culmusx' package.
% -------------------------------------------
%
% \fi
%
%% who we are
\ProvidesPackage{culmusx}[2013/08/01 v0.5 Extended Support for the Hebrew Culmus fonts]
%
\DeclareOption{rtlcolors}{%
	\@cx@rtlcolorsdisabledfalse
}
%
\DeclareOption{UnifiedColorCommands}{
    \PassOptionsToPackage{UnifiedColorCommands}{rtlcolors}
}
\input he8enx.def
\input hx8enc.dfu
%
% cx-colors: disabled by default
\newif\if@cx@rtlcolorsdisabled\@cx@rtlcolorsdisabledtrue
%
% process options to determine whether rtl-colors are enaled.
\ProcessOptions
%
\def\cx@tmp@newif{\newif\if@rl}
\ifcsname if@rl\endcsname
% (is already defined, do nothing)
\else
    \cx@tmp@newif
\fi
%
%
\if@cx@rtlcolorsdisabled
\else
    \RequirePackage{rtlcolors}
    \def\cx@textcolor#1#{\@cx@textcolor{#1}}
    \def\@cx@textcolor#1#2#3{%
                    \if@rl%
                        \protect\leavevmode{\rtlcol@color#1{#2}\cx@GhostGlyph#3\rtlcol@color#1{#2}}%
                    \else
                        \protect\leavevmode{\rtlcol@color#1{#2}\cx@GhostGlyph#3}%
                    \fi}
    % command to be used when temporarily changing colors in the middle of a word
    \let\CulmusTextColorWithRepeatedGhostGlyph=\cx@textcolor
\fi
%
% initialize arbitrary code commands
\def\cx@PostGhostGlyphArbitraryCode{\empty}
\def\cx@PreLetterArbitraryCode{\empty}
%
% command to associate letter command with ghost glyph command
\if@cx@rtlcolorsdisabled
    \def\cx@DefineLetter#1#2#3{%
        \def#1{#2\cx@PostGhostGlyphArbitraryCode\def\cx@GhostGlyph{#2}\cx@PreLetterArbitraryCode#3}}
\else
    \def\cx@DefineLetter#1#2#3{%
        \def#1{#2\cx@PostGhostGlyphArbitraryCode\rtlcol@RtlColorCommand\def\cx@GhostGlyph{#2}\cx@PreLetterArbitraryCode#3}}
\fi
%
% associate letters with their ghost glyphs
% basic letters
\cx@DefineLetter{\HebAlef}{\HebAlefGhost}{\hebalef}
\cx@DefineLetter{\HebBet}{\HebBetGhost}{\hebbet}
\cx@DefineLetter{\HebGimel}{\HebGimelGhost}{\hebgimel}
\cx@DefineLetter{\HebDalet}{\HebDaletGhost}{\hebdalet}
\cx@DefineLetter{\HebHe}{\HebHeGhost}{\hebhe}
\cx@DefineLetter{\HebVav}{\HebVavGhost}{\hebvav}
\cx@DefineLetter{\HebZayin}{\HebZayinGhost}{\hebzayin}
\cx@DefineLetter{\HebKhet}{\HebKhetGhost}{\hebkhet}
\cx@DefineLetter{\HebTet}{\HebTetGhost}{\hebtet}
\cx@DefineLetter{\HebYod}{\HebYodGhost}{\hebyod}
\cx@DefineLetter{\HebKaf}{\HebKafGhost}{\hebkaf}
\cx@DefineLetter{\HebLamed}{\HebLamedGhost}{\heblamed}
\cx@DefineLetter{\HebMem}{\HebMemGhost}{\hebmem}
\cx@DefineLetter{\HebNun}{\HebNunGhost}{\hebnun}
\cx@DefineLetter{\HebSamekh}{\HebSamekhGhost}{\hebsamekh}
\cx@DefineLetter{\HebAyin}{\HebAyinGhost}{\hebayin}
\cx@DefineLetter{\HebPe}{\HebPeGhost}{\hebpe}
\cx@DefineLetter{\HebTsadi}{\HebTsadiGhost}{\hebtsadi}
\cx@DefineLetter{\HebQof}{\HebQofGhost}{\hebqof}
\cx@DefineLetter{\HebResh}{\HebReshGhost}{\hebresh}
\cx@DefineLetter{\HebShin}{\HebShinGhost}{\hebshin}
\cx@DefineLetter{\HebTav}{\HebTavGhost}{\hebtav}
\cx@DefineLetter{\HebAlefLamed}{\HebAlefLamedGhost}{\hebaleflamed}
%
% letters with mapiq/dagesh
\cx@DefineLetter{\HebAlefmapiq}{\HebAlefGhost}{\hebalefmapiq}
\cx@DefineLetter{\HebBetDagesh}{\HebBetGhost}{\hebbetdagesh}
\cx@DefineLetter{\HebGimelDagesh}{\HebGimelGhost}{\hebgimeldagesh}
\cx@DefineLetter{\HebDaletDagesh}{\HebDaletGhost}{\hebdaletdagesh}
\cx@DefineLetter{\HebHeMapiq}{\HebHeGhost}{\hebhemapiq}
\cx@DefineLetter{\HebVavDagesh}{\HebVavGhost}{\hebvavdagesh}
\cx@DefineLetter{\HebZayinDagesh}{\HebZayinGhost}{\hebzayindagesh}
\cx@DefineLetter{\HebKhetDagesh}{\HebKhetGhost}{\hebkhetdagesh}
\cx@DefineLetter{\HebTetDagesh}{\HebTetGhost}{\hebtetdagesh}
\cx@DefineLetter{\HebYodDagesh}{\HebYodGhost}{\hebyoddagesh}
\cx@DefineLetter{\HebKafDagesh}{\HebKafGhost}{\hebkafdagesh}
\cx@DefineLetter{\HebLamedDagesh}{\HebLamedGhost}{\heblameddagesh}
\cx@DefineLetter{\HebMemDagesh}{\HebMemGhost}{\hebmemdagesh}
\cx@DefineLetter{\HebNunDagesh}{\HebNunGhost}{\hebnundagesh}
\cx@DefineLetter{\HebSamekhDagesh}{\HebSamekhGhost}{\hebsamekhdagesh}
\cx@DefineLetter{\HebAyinDagesh}{\HebAyinGhost}{\hebayindagesh}
\cx@DefineLetter{\HebPeDagesh}{\HebPeGhost}{\hebpedagesh}
\cx@DefineLetter{\HebTsadiDagesh}{\HebTsadiGhost}{\hebtsadidagesh}
\cx@DefineLetter{\HebQofDagesh}{\HebQofGhost}{\hebqofdagesh}
\cx@DefineLetter{\HebReshDagesh}{\HebReshGhost}{\hebreshdagesh}
\cx@DefineLetter{\HebShinDagesh}{\HebShinGhost}{\hebshindagesh}
\cx@DefineLetter{\HebTavDagesh}{\HebTavGhost}{\hebtavdagesh}
%
% shin with shin/sin dot: same ghost for all
\cx@DefineLetter{\HebShinWithDot}{\HebShinGhost}{\hebshinwithdot}
\cx@DefineLetter{\HebSinWithDot}{\HebShinGhost}{\hebsinwithdot}
\cx@DefineLetter{\HebShinDageshDot}{\HebShinGhost}{\hebshindageshdot}
\cx@DefineLetter{\HebSinDageshDot}{\HebShinGhost}{\hebsindageshdot}
%
% vowels
\def\HebSchwa{\hebschwa\cx@GhostGlyph}
\def\HebHatafSegol{\hebhatafsegol\cx@GhostGlyph}
\def\HebHatafPatah{\hebhatafpatah\cx@GhostGlyph}
\def\HebHatafQamats{\hebhatafqamats\cx@GhostGlyph}
\def\HebHiriq{\hebhiriq\cx@GhostGlyph}
\def\HebTsere{\hebtsere\cx@GhostGlyph}
\def\HebSegol{\hebsegol\cx@GhostGlyph}
\def\HebPatah{\hebpatah\cx@GhostGlyph}
\def\HebQamats{\hebqamats\cx@GhostGlyph}
\def\HebHolam{\hebholam\cx@GhostGlyph}
\def\HebQubuts{\hebqubuts\cx@GhostGlyph}
%
\newcommand{\TestVowelKerning}[1]{\def\TestVowel{#1}%
    \beginR
    \HebAlef\TestVowel\space%
    \HebBet\TestVowel\space%
    \HebGimel\TestVowel\space%
    \HebDalet\TestVowel\space%
    \HebHe\TestVowel\space%
    \HebVav\TestVowel\space%
    \HebZayin\TestVowel\space%
    \HebKhet\TestVowel\space%
    \HebTet\TestVowel\space%
    \HebYod\TestVowel\space%
    \HebKaf\TestVowel\space%
    \HebLamed\TestVowel\space%
    \HebMem\TestVowel\space%
    \HebNun\TestVowel\space%
    \HebSamekh\TestVowel\space%
    \HebAyin\space%
    \HebAyin\TestVowel\space%
    \HebPe\TestVowel\space%
    \HebTsadi\TestVowel\space%
    \HebQof\TestVowel\space%
    \HebResh\TestVowel\space%
    \HebShin\TestVowel\space%
    \HebShin\hebshindot\TestVowel\space%
    \HebShin\hebsindot\TestVowel\space%
    \HebShinWithDot\TestVowel\space%
    \HebSinWithDot\TestVowel\space%
    \HebTav\TestVowel\space%
    %\HebAlefLamed\TestVowel\space%
%
    \beginR
    \HebAlef\hebdagesh\TestVowel\space%
    \HebBet\hebdagesh\TestVowel\space%
    \HebGimel\hebdagesh\TestVowel\space%
    \HebDalet\hebdagesh\TestVowel\space%
    \HebHe\hebdagesh\TestVowel\space%
    \HebVav\hebdagesh\TestVowel\space%
    \HebZayin\hebdagesh\TestVowel\space%
    \HebKhet\hebdagesh\TestVowel\space%
    \HebTet\hebdagesh\TestVowel\space%
    \HebYod\hebdagesh\TestVowel\space%
    \HebKaf\hebdagesh\TestVowel\space%
    \HebLamed\hebdagesh\TestVowel\space%
    \HebMem\hebdagesh\TestVowel\space%
    \HebNun\hebdagesh\TestVowel\space%
    \HebSamekh\hebdagesh\TestVowel\space%
    \HebAyin\TestVowel\space%
    \HebPe\hebdagesh\TestVowel\space%
    \HebTsadi\hebdagesh\TestVowel\space%
    \HebQof\hebdagesh\TestVowel\space%
    \HebResh\hebdagesh\TestVowel\space%
    \HebShin\hebdagesh\TestVowel\space%
    \HebShinWithDot\hebdagesh\TestVowel\space%
    \HebSinWithDot\hebdagesh\TestVowel\space%
    \HebShin\hebshindot\hebdagesh\TestVowel\space%
    \HebShin\hebsindot\hebdagesh\TestVowel\space%
    \HebTav\hebdagesh\TestVowel\space%
}
%
\endinput
