For a certain part of text, I needed to make the text bold + underlined in addition to changing the background color
I needed to do all this while maintaining hyphenation
Thus I could not use the underline command, I used Uline and also Ic ould not use the color box command, I had to use the tcolorbox.
I have only one issue which is that the Background text color does not stop where the text stops, it extends till the end of the line. IS there any Fix for This
HERE IS THE LINK FOR SIMPLIFIED ARABIC FONT, INSTALL IT ON YOUR SYSTEM TO RUN THE CODE: https://fontzone.net/font-details/simplified-arabic
I Am using polyglossia + xelatex Here is the code with various examples:
\documentclass[a4paper,12pt,twoside]{book}
\usepackage
[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry}
\usepackage{fontspec}
\usepackage{tcolorbox}
\usepackage{ulem}
\usepackage[hidelinks,colorlinks=true,linkcolor = blue,anchorcolor = blue,citecolor = blue,filecolor = blue,urlcolor = blue]{hyperref}
\usepackage{url,graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows,positioning,matrix,quotes, shapes.geometric,calc}
\usepackage{rotating}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=gregorian,locale=default,numerals=mashriq]{arabic}
\setotherlanguages{english}
\newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits]{Simplified Arabic}
\begin{document}
\chapter{}
\begin{bfseries}
\begin{tcolorbox}
[colframe=white,colback=lightgray]
\uline{
لتسهيل عملية الدراسة، من المحبب ان يبدأ الطالب بالدراسة من خلال ملحق رقم (2) لإحتوائه على أهم القواعد اللغوية المطلوبة لإتقان المواضيع الموضحة بفصول الكتاب المختلفة وذلك تسهيلاً على الطالب حتى يتجنب كثرة التفاصيل.}
\end{tcolorbox}
\end{bfseries}
\bigskip
\underline{\textbf{\colorbox{lightgray}{
لتسهيل عملية الدراسة، من المحبب ان يبدأ الطالب بالدراسة من خلال ملحق رقم (2) لإحتوائه على أهم القواعد اللغوية المطلوبة لإتقان المواضيع الموضحة بفصول الكتاب المختلفة وذلك تسهيلاً على الطالب حتى يتجنب كثرة التفاصيل.}}}
\bigskip
\uline{\textbf{\colorbox{lightgray}{
لتسهيل عملية الدراسة، من المحبب ان يبدأ الطالب بالدراسة من خلال ملحق رقم (2) لإحتوائه على أهم القواعد اللغوية المطلوبة لإتقان المواضيع الموضحة بفصول الكتاب المختلفة وذلك تسهيلاً على الطالب حتى يتجنب كثرة التفاصيل.}}}
\begin{bfseries}
\begin{tcolorbox}
[colframe=white,colback=lightgray]
\underline{
لتسهيل عملية الدراسة، من المحبب ان يبدأ الطالب بالدراسة من خلال ملحق رقم (2) لإحتوائه على أهم القواعد اللغوية المطلوبة لإتقان المواضيع الموضحة بفصول الكتاب المختلفة وذلك تسهيلاً على الطالب حتى يتجنب كثرة التفاصيل.}
\end{tcolorbox}
\end{bfseries}
\end{document}

bfseriesis not an environment but a switch: (\bfseries) – leandriis Aug 18 '19 at 09:08\hlcommand fromsoul(or rathersoulutf8)? – Bernard Aug 18 '19 at 09:16