# texts in equations not being showed properly using xepersian package

I'd like to insert an equation in my $LaTeX$ document that looks like the following equation but I fail to make it show the text inside the equation:

and the output I am getting:

I read questions\answers regarding the combination of Persian and English in xepersian and used \lr and latin but it doesn't work. What am I doing wrong?

Here is the MWE:

\documentclass[a4paper,12pt]{report}
\usepackage{titlesec}
\usepackage{xepersian}
\usepackage{./styles/tempfix}
\settextfont[Scale=1.1]{B Nazanin}
\defpersianfont\nastaliq[Scale=2]{IranNastaliq}
\defpersianfont\titr[Scale=1]{B Titr}
\defpersianfont\traffic[Scale=1]{B Traffic}
\deflatinfont\calibri{Calibri}
\begin{document}

$$P_J{:}\quad \min_{x} J(x) \quad \textrm{subject to} \quad y=Dx %P_J{:}\quad \min_{x} J(x) \quad \lr\textrm{subject to} \quad y=Dx$$
\end{document}

• Quick guess: maybe \text{} and \mathrm{} could be useful. See also this question. – Karlo Aug 16 '16 at 11:16
• Minimal example? – egreg Aug 16 '16 at 11:17
• Oh \mathrm{} works, thank you for the quick guess @Karlo! :) – Gigili Aug 16 '16 at 11:26
• Not a minimal example: I get an error: You have not specified any font for the main Persian text. – egreg Aug 16 '16 at 11:46
• @egreg oops, sorry! Edited. – Gigili Aug 16 '16 at 11:59

Your Persian font doesn't seem to support Latin character. If I use Scheherazade, it does:

\documentclass[a4paper,12pt]{report}

\usepackage{unicode-math}
\usepackage{xepersian}

\setmainfont{TeX Gyre Termes}
\setmathfont{XITS Math}

\begin{document}

$$P_J{:}\quad \min_{x} J(x) \quad \textrm{subject to} \quad y=Dx$$

\end{document}


Alternatively,

\documentclass[a4paper,12pt]{report}
\usepackage{amsmath}
\usepackage{xepersian}

$$P_J{:}\quad \min_{x} J(x) \quad \textnormal{\lr{subject to}} \quad y=Dx$$