latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
239 stars 28 forks source link

Better support for Arabic math #633

Open khaledhosny opened 3 months ago

khaledhosny commented 3 months ago

Status

UNDER DEVELOPMENT

Description

Improve handling of Arabic math symbols.

  1. Allow Arabic math alphabets to be used when unicode-math is loaded, previously they would always be using CMMI fonts.
  2. Fix spacing of Arabic comma by making sure it gets punctuation math class.

Todo

Minimal example demonstrating the new/fixed functionality

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{XITSMath-Regular.otf}
\usepackage{ifluatex}
\begin{document}
\ifluatex\mathdir TRT\fi
\[
  \mAlef + \mBeh = \minitialJeem
\]
\end{document}
khaledhosny commented 3 months ago

I want to also implement math mapping for Arabic, so using regular Arabic letters in math mode would map to math alphanumerics like with Latin and Greek. I looked into um-code-mathmap.dtx and um-code-alphabets.dtx but I’m still not sure how this works.

I’d need new initial, tailed, looped, and extended math styles, as well as adding Arabic mapping to bb style.

I’m not sure what style to use for the first Arabic math alphabet; it is functionally equivalent to math italics, but it is not italic (there is not italic style in Arabic, but it it is not even slanted), so up would be a better fit, but what about the regular Arabic letters? (they are sometimes used in math, e.g. math dal is used for variables while regular dal is used for function, similar f()), so may be use it for the math alphabet and up for the regular one.

\mathnormal would map to regular Arabic letters, up if we go with the scheme above, to it except for heh (it has no it form) and jeem (initial form is used).

I appreciate any guidance on how to achieve this.

khaledhosny commented 3 months ago

The last commit is my attempt to do the above (mostly copy/paste), but it does not seem to do any thing. I don’t actually think any of the code I added is being used.

davidcarlisle commented 3 months ago

@khaledhosny thanks for this, Possibly can't review this weekend, but will look later, also if there are any updates needed in TR25 that may also be possible.

khaledhosny commented 3 months ago

@khaledhosny thanks for this, Possibly can't review this weekend,

Thanks.

also if there are any updates needed in TR25 that may also be possible.

I think MathClass-15.txt is missing an entry for 060C giving it a P class (as well as my comment in https://github.com/latex3/unicode-math/issues/619#issuecomment-2028785695).

wspr commented 3 months ago

Thanks @khaledhosny — and please don't hesitate to keep this on my radar if I seem to disappear for a while, it's a bit of a crazy year.

I would if we should we have this set up by default with all fonts, or is there more that needs to be done via OpenType features etc such that it would make sense to require an explicit option (which could use a heuristic to activate automatically) ?

khaledhosny commented 2 months ago

Thanks @khaledhosny — and please don't hesitate to keep this on my radar if I seem to disappear for a while, it's a bit of a crazy year.

Thanks, no pressure.

I would if we should we have this set up by default with all fonts, or is there more that needs to be done via OpenType features etc such that it would make sense to require an explicit option (which could use a heuristic to activate automatically) ?

Typesetting Arabic math requires also right-to-left support in math mode, which is currently available in LuaTeX only and requires fiddling with low-level primitive. The changes here are prerequisite for further improvement in this area, as without this you can’t use Arabic math alphabets at all.