Texnegar with Arabic poems in LuaLaTeX

Issue #1 closed
Yacine created an issue

I am trying to work on an Arabic poetry text in LuaLaTeX using bidipoem or ArabLuaTeX packages but texnegar does not seem to work with the poetry environments.

I have created an issue on StackExchange, but there were no solutions found. I appreciate any comment on the issue. Here is the link: https://tex.stackexchange.com/questions/578996/is-it-possible-to-make-texnegar-work-with-arabic-poems-in-lualatex

Comments (7)

  1. Hossein Movahhedian repo owner

    Unfortunately, I am not familiar with babel nor with arabluatex.
    However, with the "HM XKayhan" and the "Scheherazade" fonts,
    everything works fine on my system except with the arabverse
    environment. By looking at arabluatex code, I'll try to add some
    options to texnegar to fix this problem, and in case of success, I
    will report here.

  2. Hossein Movahhedian repo owner

    One solution to this issue is to redefine the command \bayt as follows:

    \documentclass[A4paper,11pt]{book}
    % \usepackage[Kashida=leaders+glyph,kashidastretch=0.14 em plus 0.5 em,hboxrecursion=On,vboxrecursion=On,color=red,ligatures=default]{texnegar}
    \usepackage[Kashida=glyph,kashidastretch=0.14 em plus 0.5 em,hboxrecursion=On,vboxrecursion=On,color=red,ligatures=default]{texnegar}
    \usepackage[bidi=default]{babel}
    \babelprovide[import=ar-DZ, main]{arabic}
    % \babelfont{rm}[Language=Default,Scale=2]{Scheherazade}
    % \babelfont{sf}[Language=Default,Scale=2]{Scheherazade}
    \babelfont{rm}[Language=Default,Scale=2]{HM XKayhan}
    \babelfont{sf}[Language=Default,Scale=2]{HM XKayhan}
    \babelfont[french]{rm}{Junicode}
    \babeltags{ar = arabic}
    \babeltags{fr = french}
    \usepackage{multicol} 
    \usepackage{color}
    \usepackage{bidipoem}
    \usepackage{arabluatex}    
    \pagestyle{empty}
    
    \makeatletter
    \RenewDocumentCommand{\bayt}{s m o m}{%
      \IfBooleanTF{#1}{\relax}{\relax}%
      \ifdefined\savenotes\savenotes\else\fi%
      \edef\al@tatweel{--}%
      \ifal@warp@bayt%
        \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#2}}%
      \else%
        % \makebox[\al@bayt@width][s]{\arb@utf{#2}}%
        \makebox[\al@bayt@width][s]{\vbox{\hsize=\al@bayt@width \KashidaOn \arb@utf{#2} \linebreak[4]}}%
      \fi%
      \IfNoValueTF{#3}{%
        \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}%
        \else%
        \hspace{\al@gutter@width}%
        \fi
      }{%
        \edef\@tempa{#3}%
        \ifx\@tempa\al@tatweel%
        \ifx\al@mode\al@mode@trans%
        \hspace{\al@gutter@width}%
        \else%
        \makebox[\al@gutter@width][s]{\al@verse@stroke}%
        \fi%
        \else%
        \ifx\al@mode\al@mode@trans%
        \ifal@warp@bayt%
          \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#3}}%
        \else%
          \makebox[\al@gutter@width][s]{\arb@utf{#3}}%
        \fi%
        \else%
        \makebox[\al@gutter@width][s]{\arb@utf{#3}}%
        \fi\fi}%
      \ifal@warp@bayt%
        \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#4}}%
      \else%
        % \makebox[\al@bayt@width][s]{\arb@utf{#4}}%
        \makebox[\al@bayt@width][s]{\vbox{\hsize=\al@bayt@width \KashidaOn \arb@utf{#4} \linebreak[4]}}%
      \fi%
      \ifdefined\spewnotes\spewnotes\else\fi%
    }
    \makeatother
    
    \begin{document}
    %Source: https://blogs.harvard.edu/sulaymanibnqiddees/tag/arabic-sufi-poetry/
    
    عــليك صلاة الله ثم سلامه   ألا يا رسول الله إنى مغرم عليك صلاة الله ثم سلامه   ألا يـا رسول الله إنى مغرم عليك صلاة الله ثم سلامه    ألا يا رسول الله إنى مغرم
    
    وَلَيسَ لَهُ مِن ذَا التَّتَيُّمِ مُشرِحٌ    سِوَى أن يَرَى مَعشُوقَهُ فَيُسَلِّمُ
     علــيك صلاة الله ثم سلامه     ألا يــا رسول الله إنى مغرم
     صَبَبتُ دُمُوعاً يَشهَدُ الحُزنُ أَنَّه   أَتَت مِن فُؤَادٍ بالغَرَامِ مُتَيَّمُ
    
    \begin{multicols}{3}
    عــليك صلاة الله ثم سلامه   ألا يا رسول الله إنى مغرم عليك صلاة الله ثم سلامه   ألا يـا رسول الله إنى مغرم عليك صلاة الله ثم سلامه    ألا يا رسول الله إنى مغرم عــليك صلاة الله ثم سلامه   ألا يـا رسول الله إنى مغرم عليك صلاة الله ثم سلامه   ألا يـا رسول الله إنى مغرم عليك صلاة الله ثم سلامه    ألا يا رسول الله إنى مغرم
    \end{multicols}
    
    \begin{arabverse}[width=.45\linewidth]
      \let\arabicfont\empty
      \StretchBayt[false]
      \bayt{ صببت دموعا }{ يشهد الحزن انها } \\
      \bayt{ أَتَت مِن فُؤَادٍ }{ بالغَرَامِ مُتَيَّمُ } \\
    \end{arabverse}
    
    \end{document}
    

  3. Yacine reporter

    Thank you for your prompt reply. Your solution worked like a charm with HM XKayhan font!

    May I ask why texnegar works only with some specific fonts, and not with Amiriand Scheherazade fonts?

  4. Hossein Movahhedian repo owner

    According to Yacine's report in SE, it seems that this is a bug in texnegar. I will try to fix it in the later versions. However, please note that the code works fine with Adobe Arabic font. Thanks for Yacine's report.

  5. Log in to comment