\documentclass[a4paper,11pt]{book}
\usepackage{rotating}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{amsthm}
\usepackage{fancybox}
\usepackage{fancyhdr}
\renewcommand{\baselinestretch}{1.2}
\usepackage{setspace}
\usepackage{makeidx}
\makeindex
\usepackage{graphicx}
\usepackage{xepersian}
\settextfont{XB Niloofar}
\setlatintextfont{Times New Roman}
\setdigitfont{ParsiDigits}
%+++++++++++++++++++++++++++++
\defpersianfont\nastaligh[Scale=1.5]{IranNastaliq}
\makeatletter
\newcommand\mycustomfont[1]{\def\@mycustomfont{#1}}
\newcommand\mycustomraggedright{%
	\if@RTL\raggedleft%
		\else\raggedright%
							\fi}

\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \mycustomraggedright \@mycustomfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
  \renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\@mycustomfont\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\@mycustomfont\large\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\@mycustomfont\normalsize\bfseries}}
\makeatother
\mycustomfont{\nastaligh}
%+++++++++++++++++++++++++++++
\defpersianfont\nastaliq[Scale=2.5]{IranNastaliq}
\defpersianfont\nastal[Scale=2]{IranNastaliq}
%here comes fancy definitions%%%%%%%%%%%%%%
\pagestyle{fancy}
% with this we ensure that the chapter and section
% headings are in lowercase.
\renewcommand{\chaptermark}[1]{%
        \markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
        \markright{\thesection\ #1}}
\fancyhf{} % delete current header and footer
\fancyhead[RO]{\slshape\leftmark}
\fancyhead[LE]{\slshape\rightmark}
\fancyhead[LO,RE]{\slshape \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\begin{document}
\tableofcontents
\newpage
%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\begin{RTL}
\nastaliq
پیشگفتار
\\
\end{RTL}
\chapter{aaaaaaaaaaa}
\chapter{bbbbbbbbbbbbb}
\chapter{cccccccccccccccc}
%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\appendix
\makeatletter
\def\thechapter{\@arabic\c@chapter}
\makeatother
\chapter{ًًًًًضضضضضضضضض}
\chapter{ قططططططططططططططططططی}

%103*********************************************************************************************************************************103
\makeatletter
\def\thechapter{\@arabic\c@chapter}
\makeatother
\chapter{آآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآآامال}
\chapter{بببببببببببببببببببببببببخث}
\chapter{پپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپپ}
\chapter{ججججججججججججججج}
\end{document}







                                                                                                         
