# tcolorbox listing in XeLaTex compiler

I want to write a document whose main language is Arabic with listings by using the package \usepackage{polyglossia}

\documentclass[14pt]{extarticle}
\usepackage[listings,minted,breakable,skins]{tcolorbox}
\usepackage{polyglossia}
\newfontfamily\arabicfont[Script=Arabic,Scale=1,Path=fonts/]{flat.ttf} %my
favortie main font
\newfontfamily\timesnewroman[Script=Arabic,Scale=1,Path = fonts/]{times.ttf}
\setmainlanguage[numerals=maghrib]{arabic} %My main & native language
\setotherlanguage{english}
\begin{document}
هذا كود برمجي بسيط
\begin{english}
\begin{tcblisting}{enhanced,listing only,minted language=latex}
my name is \textcolor{red}{Muhammad}
hi
\end{tcblisting}
\end{english}
\end{document}


However, I encountered two problems:

1. Although the output itself is not problematic as shown below, I get the following message after compiling:

Package polyglossia Error: the current roman font does not contain the  Arabic script


As an attempt to solve this error, I changed the monofont into an existing custom font and it quite works\setmonofont[Scale=1,Path = fonts/]{times.ttf}, but the output looks ugly and there is a problem with the curly brackets as shown below. Is there a way to avoid this error without changing the default mono font or the traditional one?

2. Nevertheless the polyglossia problem, when I indent the codes by pressing Tab,

\documentclass[14pt]{extarticle}
\usepackage[listings,minted,breakable,skins]{tcolorbox} %very essential package to produce chat boxes
\begin{document}
\begin{tcblisting}{enhanced,listing only,minted language=latex}
my name is \textcolor{red}{Muhammad}
hi
\end{tcblisting}
\end{document}


The indented spaced are replaced with ^^I However, if I switch the compiler to pdflatex, no indented spaces are produced

• For the second see tex.stackexchange.com/a/264463/2388 – Ulrike Fischer Dec 5 '18 at 17:24
• You do not need Script=Arabic option for times.ttf because it does not contain arabic script, another thing you have defined \timesnewroman font but you did not use it in the first example. – Salim Bou Dec 5 '18 at 17:50
• @UlrikeFischer In fact, I am newbie in LaTeX using TeXnic center, however I guessed I should put -8bit in command line arguments according to the link you commented and the listing works in xelatex as fine as in pdflatex. One another question: I cannot indent the first line of the code listing, is it normal or there is something wrong? – Muhammed Hashim Dec 5 '18 at 18:04
• @SalimBou If you mean setting the mono font, I haven't set the option Script=Arabic. – Muhammed Hashim Dec 5 '18 at 18:08