I used this solution by a user Cicada from one of the questions on how to type Unicode characters in math mode:
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{polyglossia}
\setmainlanguage{arabic}
% Credits: Cicada's answer from https://bit.ly/3dpDg9t
\setmainfont[Script=Arabic]{Amiri}
\DeclareSymbolFont{arabicletters}{\encodingdefault}{Amiri(0)}{m}{n}
\newcommand{\makearabicmathletter}[1]{%
\begingroup\lccodea=#1\lowercase{\endgroup \Umathcodea}="0 \csname symarabicletters\endcsname\space #1
}
% Normal Arabic Letters
\count255="0605
\loop\ifnum\count255<"064B
\makearabicmathletter{\count255}
\advance\count255 by 1
\repeat
% Arabic Mathematical Symbols!!!!!!
\count255="1EE00
\loop\ifnum\count255<"1EEBB
\makearabicmathletter{\count255}
\advance\count255 by 1
\repeat
\begin{document}
[
\frac{م}{2؈} = ط
]
[\char126555 + م]
\end{document}
The first loop seems to work well. I can directly type Arabic letters. However, since the latter loop deals with glyphs which don't exist on usual keyboards, my only chance of using them was to directly type in the character code. However it gave me an error:
! Bad character code (126555).
l.27 \char126555
Overleaf went as far as telling me that I can't use any character number above 65535. What should I do? And why did it work for Cicada, when they used Egyptian hieroglyphics, and not now?
EDIT: Credit where credit's due, the user egreg discovered the lccode trick.


lcctrick is @egreg 's. – Cicada Apr 18 '21 at 06:10