reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
187 stars 52 forks source link

Incorrect Arabic numbering #589

Closed ghost closed 1 year ago

ghost commented 1 year ago

I have this simple code:

\documentclass[a4paper]{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\setmainfont{Amiri} 

\begin{document}
\tableofcontents
\chapter{العنوان}
العنوان الأول
\section{العنوان الثاني}
\subsection{الثالث}
\end{document}

In the sections and subsections, the resulting numbers are 101 and 10101 Instead of 1.1 and 1.1.1

So instead of '.' it is putting a '0' (that is in Arabic numbers). Screenshot from 2023-05-02 13:46:51

jspitz commented 1 year ago

Alas I can't read Arabic script, so I might be talking nonsense, but if I'm inputting literal dots I get the very same glyph. Are you sure this isn't a font issue? In polyglossia, we do not modify the decimal separator, so this is basically what XeTeX (bidi?) outputs.

jspitz commented 1 year ago

Also consider this:

% !TeX TS-program = xelatex
\documentclass[a4paper]{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\setmainfont{Amiri} 

\begin{document}
    \tableofcontents
    \setcounter{chapter}{9}
    \chapter{العنوان}
    العنوان الأول
    \section{العنوان الثاني}
    \subsection{الثالث}
\end{document}

I'd say the zero is positioned higher: grafik

jspitz commented 1 year ago

@khaledhosny could you please have a look whether there is something wrong here, and if so, instruct us which glyph would be expected as section separator with Arabic digits?

ghost commented 1 year ago

This issue happens on ubuntu. On archlinux it renders fine: Screenshot_20230503_09-22-29 This is how it should look like.

ghost commented 1 year ago

The diamond in arabic is a zero ( ٠ ) The round dot is a decimal place indicator ( . )

It is rendered incorrectly in your sample arabic example here: https://github.com/reutenauer/polyglossia/blob/master/generated/example-arabic.pdf

khaledhosny commented 1 year ago

In Amiri Arabic-Indic zero and peroid look close (but have different baselines). Period is not a good number seperator in Arabic since it is too close in shape to zero (and some fonts have both rounded, too).

I suggest using a dash-like character for Arabic, may be en-dash or hyphen-minus.

jspitz commented 1 year ago

Thanks @khaledhosny. Is one among these reasonably common or would you propose to add an option to select among the period and en-dash?

khaledhosny commented 1 year ago

hyphen-minus should be available on most fonts, en-dash is probably rarer in Arabic fonts. An option is probably desirable since people might prefer another separator entirely (I have not surveyed Arabic publications, but this way of numbering is rather unfamiliar to me).

jspitz commented 1 year ago

For xetex (bidi) we can simply re-use \SepMark{-}. Alas, luabidi doesn't know this, so we need to redefine all section commands.

jspitz commented 1 year ago

I've implemented an option sectionsep (e.g., [sectionsep=-]) to arabic which works both with xe and lua. Testing welcome.

jspitz commented 1 year ago

I've implemented the same option to Kurdish, Persian, Syriac, and Urdu, which also use Eastern Arabic numerals