Malayalam Page Numbers in XeLatex

Recently I had an opportunity to be a part of an effort to enable SCERT(The Govt. organization which is responsible for the content, curriculum and the textbooks which are used in the schools of the state) to use unicode technologies for textbook publishing.

As part of this effort, we tried to typeset Malayalam textbooks for 5th, 7th and 11th standards using xelatex.

I wrote the following macro to automatically generate the page numbers using malayalam numerals

    %%%———–Malayalam Page Number—————%%%%

    \makeatletter
    \def\@malnumber#1{\expandafter\@@malnumber\number#1\@nil}
    \def\@@malnumber#1{%
    \ifx#1\@nil
    \else
    \char\numexpr#1+”0D66\relax
    \expandafter\@@malnumber\fi}
    \def\malcounter#1{\expandafter\@malnumber\csname c@#1\endcsname}
    \def\malnumeral#1{\@@malnumber#1\@nil}
    \makeatother

    \def\MalpageNum{\malcounter{page}}

The \MalpageNum command will provide the current page number using the Malayalam numerals.

Happy Hacking!!