[XeTeX] Color Hebrew Vowel Points

François Charette firmicus at ankabut.net
Wed Aug 1 10:13:18 CEST 2007


(Sorry to jump a bit late into this thread.)

Thanks Jonathan for your nice hack with overprinting.

Just for completion, here is what I did for coloring vowels in Arabic 
(same can be done for Hebrew or Syriac) without the need to enter the 
text twice (vocalized and non-vocalized):

    \documentclass{article}
    \usepackage{fontspec}
    \usepackage[novoc]{arabxetex}
    \setromanfont[Mapping=tex-text]{Junicode}%{FPL Neu}
    \newfontfamily\arabicfont[Script=Arabic]{Scheherazade}

    % this is for UTF-8 input (arabxetex not required)
    \newcommand\arabcolorvowels[1]{%
      \setbox0=\hbox{\RL{\arabicfont\addfontfeature{Color=FF0000}#1}}%
     
    \setbox2=\hbox{\RL{\arabicfont\addfontfeature{Mapping=arabic-novowels}#1}}%
      \ifdim\wd0=\wd2 \else
        \message{WARNING: width mismatch: #1}\fi
      \leavevmode \hbox{\beginL\box0
        \kern-\wd2 \box2\endL}
    }
    % and this is for input in ArabTeX notation:
    \newcommand\arabtexcolorvowels[1]{%
      \setbox0=\hbox{\textarab[fullvoc]{\addfontfeature{Color=FF0000}#1}}%
      \setbox2=\hbox{\textarab[novoc]{#1}}%
      \ifdim\wd0=\wd2 \else
        \message{WARNING: width mismatch: #1}\fi
      \leavevmode \hbox{\beginL\box0
        \kern-\wd2 \box2\endL}
    }

    \begin{document}
    \arabcolorvowels{اَلْمَدِينَة اَلْفَاضِلَة}
    \arabtexcolorvowels{al-madInaT al-fA.dilaT}
    \end{document}



The mapping arabic-novowels can be obtained by running teckit_compile on 
a file arabic-novowels.map that contains these few lines:

    LHSName  "Arab-Unicode"
    RHSName  "Arab-Unicode-novowels"

    pass(Unicode)
    Class [VWL]  = (U+064B..U+065E U+0670);

    [VWL] > ;



Best,
François

Jonathan Kew a écrit :
> On 24 Jul 2007, at 9:41 pm, Joshua Grauman wrote:
>
>   
>> I would like to try your last suggestion about overprinting.  
>> However, I
>> don't have any idea how to "overprint" either in XeTeX or  
>> OpenOffice or
>> whatever. Frankly, I would like to use OpenOffice to create the  
>> charts.
>> For making a critical edition XeTeX is great, for a simple chart...
>> Anyway, I was wondering if any of you ps/pdf experts knew how to  
>> overlay
>> two ps files like Jonathan is suggesting... Thanks.
>>     
>
> I see you've got a solution, so this may not be relevant, but perhaps  
> someone will find a use for it in the future... anyhow, if you were  
> prepared to tackle it in XeTeX it would be pretty easy. Here's a  
> possible approach:
>
>    \TeXXeTstate=1
>    \font\redfont="Ezra SIL:script=hebr;color=FF0000" at 24pt
>    \font\blkfont="Ezra SIL:script=hebr" at 24pt
>
>    \def\redandblack#1x#2{\blkfont
>      % print text #1 in red, then overlay #2 in black
>      \setbox0=\hbox{\redfont\beginR #1\endR}%
>      \setbox2=\hbox{\blkfont\beginR #2\endR}%
>      \ifdim\wd0=\wd2 \else
>        \message{WARNING: width mismatch: #1 and #2}\fi
>      \leavevmode \hbox{\beginL\box0
>        \kern-\wd2 \box2\endL}}
>
>    \noindent\beginR
>      \redandblack{בְּרֵאשִׁית}x{בּראשית}
>      \redandblack{בָּרָא}x{בּרא}
>      \redandblack{אֱלֹהִים}x{אלהים}
>      % etc
>
>    \end
>
> Note that the third word here is an example where the dot on lamed  
> *does* modify the spacing, and therefore the results will not be as  
> desired. The SBL Hebrew font would be another option; there, the dot  
> causes only a very small change to spacing, so the result might be  
> acceptable. If you want the dagesh colored as well, SBL Hebrew  
> definitely works better.
>
> This could of course be used within table cells, or whatever, just as  
> well as in a normal paragraph. The same technique could be used to  
> print Arabic with colored vowels, etc.
>
> For advanced TeX macro programmers: in principle, it should be  
> possible to set up macros to automatically do this to running text,  
> rather than add macros throughout. Anyone up for a challenge? :-)
>
> JK
>
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex
>   




More information about the XeTeX mailing list