6

To type arabic with the same keyboard layout I used to use on Windows 10, I've created a .mim file (key mapping file) and put it in /usr/share/m17n to make it work with ibus-m17n on Ubuntu 18.04 LTS based KDE Neon. Everything except the ornated parenthesis, normal parenthesis, braces, brackets and angle brackets works as I expect. Here's my tex document:

\documentclass{article}
\usepackage{harfload, fontspec, arabluatex}
\usepackage[a4paper, margin=1in]{geometry}
%\setmainfont{Kalpurush}[RawFeature={mode=harf}]
\newfontfamily\arabicfont[Script = Arabic]{Al Qalam Quran Majeed Web} 
\newcommand{\textarabic}[1]{\bgroup\textdir TRT\arabicfont #1\egroup}     % Arabic inside LTR
\newcommand{\n}[1]{\bgroup\textdir TLT #1\egroup}     % for digits inside Arabic text
\newcommand{\afootnote}[1]{\footnote{\textarabic{#1}}}     % Arabic footnotes
\newenvironment{Arabic}{\textdir TRT\pardir TRT\arabicfont}{}     % Arabic paragraph
\parindent 0pt
\begin{document}
    \textarabic{﴾وَصِيَّةً﴿ مِّنَ ٱللّٰه} \\
    \textarabic{(وَصِيَّةً) مِّنَ ٱللّٰه} \\ 
    \textarabic{\{وَصِيَّةً\} مِّنَ ٱللّٰه} \\
    \textarabic{[وَصِيَّةً] مِّنَ ٱللّٰه} \\
    \textarabic{<وَصِيَّةً> مِّنَ ٱللّٰه}   
\end{document}

Here's what I've got:

enter image description here

Is it a harflatex/lualatex problem or have I missed something in making my keyboard layout? here's how the mapping looks like:

;; It's an edited copy of "ar-kbd.mim" file.
(input-method ar phonetic)
(description "Arabic Phonetic (MS Windows).")
(title "ض")

(map
 (arabic
  ("`" "`")
  ("1" "١")
  .
  .
  .
  ("[" "[")
  ("]" "]")
  ("a" "ا")
  .
  .
  .
  ("\(" "\(")
  ("\)" "\)")
  .
  .
  .
  ("{" "{")
  ("}" "}")
  .
  .
  .
  ("<" "<")
  (">" ">")
  .
  .
  .
  ((G-9) "﴾")
  ((G-0) "﴿")
  .
  .
  .
  ((KP_Add) "+")
  ((KP_Subtract) "-")
  )
)

(state
 (init
  (arabic)))

I've added the output libreoffice profuced for anyone who knows how to fix those in libreoffice writer.

  • 1
    Did you mark the paragraph right-to-left in LibreOffice? The output you show would happen if you input Arabic text and a paragraph marked left-to-right. – Khaled Hosny Jul 6 '19 at 22:07
  • Yes! the pi with arrow on right solved the problem. – user189833 Jul 7 '19 at 4:38
9

arabluatex gets it more or less right. For braces you should according to the documentation use \abraces, the ornamental parentheses are intentional not mirrored in Unicode:

\documentclass{article}
\usepackage{arabluatex}
\newfontfamily\arabicfont{Amiri}[Script = Arabic]
\begin{document}
    \arb{﴾وَصِيَّةً﴿ مِّنَ ٱللّٰه} \\
    \arb{(وَصِيَّةً) مِّنَ ٱللّٰه} \\
    \arb{\{وَصِيَّةً\} مِّنَ ٱللّٰه} \\
    \arb{\abraces{وَصِيَّة} مِّنَ ٱللّٰه} \\
    \arb{[وَصِيَّةً] مِّنَ ٱللّٰه} \\
    \arb{<وَصِيَّةً> مِّنَ ٱللٰه}
\end{document}

enter image description here

luahblatex with luaotfload 3.11 gets it right too (again with the exception of the ornamental parenthese, which are intentional not mirrored in Unicode):

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\arabicfont{Amiri}[Script = Arabic,Renderer=Harfbuzz]
\newcommand{\textarabic}[1]{\bgroup\textdir TRT\arabicfont #1\egroup} 
\begin{document}
    \textarabic{﴾وَصِيَّةً﴿ مِّنَ ٱللّٰه} \\
    \textarabic{(وَصِيَّةً) مِّنَ ٱللّٰه} \\
    \textarabic{\{وَصِيَّةً\} مِّنَ ٱللّٰه} \\
    \textarabic{[وَصِيَّةً] مِّنَ ٱللّٰه} \\
    \textarabic{<وَصِيَّةً> مِّنَ ٱللٰه}
\end{document}

enter image description here

with standard luatex it fails, also as luaotfload/the fontloader ignores the bidi-mirrored feature, see https://github.com/u-fischer/luaotfload/issues/61

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\arabicfont{Amiri}[Script = Arabic]
\newcommand{\textarabic}[1]{\bgroup\textdir TRT\arabicfont #1\egroup} 
\begin{document}
    \textarabic{﴾وَصِيَّةً﴿ مِّنَ ٱللّٰه} \\
    \textarabic{(وَصِيَّةً) مِّنَ ٱللّٰه} \\
    \textarabic{\{وَصِيَّةً\} مِّنَ ٱللّٰه} \\
    \textarabic{[وَصِيَّةً] مِّنَ ٱللّٰه} \\
    \textarabic{<وَصِيَّةً> مِّنَ ٱللٰه}
\end{document}

enter image description here

| improve this answer | |
  • I'd a reference to arabluatex in the usepackage directive, why didn't it work? – user189833 Jul 5 '19 at 15:31
  • 1
    You didn't use it. The command of arabluatex is \arb (and it has a quite long documentation, so better check it ...). – Ulrike Fischer Jul 5 '19 at 15:41
  • Ornamented parens actually work with arabluatex, one has to use 2 parens instead of 1. – user189833 Jul 5 '19 at 16:48
  • and to get most out of arabluatex, I've to use fonts like Amiri. For example \ayah{11} doesn't work with the font I used BUT with Amiri it does. – user189833 Jul 5 '19 at 17:00
  • 3
    The ornamental parentheses are intentional not mirrored in Unicode, so they should be reversed in the input text, unlike the rest of parentheses. – Khaled Hosny Jul 6 '19 at 22:05
1

[Edited] [Note: this is not an answer, but a simple additional remark]

This works with standard luatex, but LRE, RLE, and PDF Characters (Pop Directional Formatting) have been used. However, most of the fonts print these marksluaotfload has them printed by default (see the screenshot below).

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\arabicfont{Amiri}[Script = Arabic]
\begin{document}
\pardir TRT\textdir TRT\arabicfont\noindent
‪﴿‬وَصِيَّةً‪﴾‬ مِّنَ ٱللّٰه\\
‪)‬وَصِيَّةً‪(‬ مِّنَ ٱللّٰه\\
‪\}‬وَصِيَّةً‪\{‬ مِّنَ ٱللّٰه\\
‪]‬وَصِيَّةً‪[‬ مِّنَ ٱللّٰه\\
‪>‬وَصِيَّةً‪<‬ مِّنَ ٱللّٰه\\
\end{document}

enter image description here

| improve this answer | |
  • 3
    Printing the BiDi marks is a bug in luaotfload's font loader github.com/u-fischer/luaotfload/issues/63 – Khaled Hosny Jul 10 '19 at 1:08
  • 1
    @KhaledHosny Thank you. My mistake: now I remember that this issue is not a font-related one. It would be great to be able to have these marks not printed by default while keeping the possibility to print them for testing purposes. – Robert Alessi Jul 10 '19 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy