3

MWE:

 \documentclass[12pt]{article}
 \usepackage{xcolor}
\usepackage[voc]{arabxetex}

\setmainfont{AlQalamQuranMajeedWeb} \newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{AlQalamQuranMajeedWeb}

\definecolor{Kalkola}{HTML}{EE171F} % \newcommand{\kal}{\color{Kalkola}}%

\begin{document} {\Huge\begin{arab} sub".ha"A \end{arab} } \end{document}

This provides:

enter image description here
I would like to get:

enter image description here

Salim Bou
  • 17,021
  • 2
  • 31
  • 76
Sofia
  • 167

2 Answers2

2

This is the best I could do in XeTeX. It's strange how the first joiner aligns well but the second joiner doesn't when colored. This may be a bug in arabxetex package. It may improve in newer version.

The full code:

\documentclass[12pt]{article}
 \usepackage{xcolor}
\usepackage[voc]{arabxetex}

\setmainfont{AlQalamQuranMajeedWeb.ttf} \newfontfamily\arabicfont[Script=Arabic, Scale=1.1]{AlQalamQuranMajeedWeb.ttf}

\definecolor{Kalkola}{HTML}{EE171F} % \newcommand{\kal}{\textcolor{Kalkola}}%

\begin{document} {\Huge\begin{arab} su-\kal{-b"-}-.ha"A

su-b"-.ha"A

\end{arab}} \end{document}

![Arabic example 1

But alternatively you can try arabluatex instead. This one works very well:

Arabic sample 2

The full code for LuaTeX:

\documentclass[12pt]{article}

\usepackage{arabluatex} \newfontfamily\arabicfont{AlQalamQuranMajeedWeb.ttf}[Script=Arabic]

\usepackage{xcolor} \definecolor{Kalkola}{HTML}{EE171F} % \newcommand{\kal}{\textcolor{Kalkola}}%

\begin{document}

{\Huge \begin{arab}[fullvoc] su\kal{b}.hA \end{arab}}

\end{document}

SolidMark
  • 1,389
2

Graphically clipping three copies of the word works, but requires manual adjustment of the position of the clip start/end:

clipped text

(based on egreg's answer at Character with two colors)

MWE

\documentclass[12pt]{article}
 \usepackage{xcolor}
\usepackage{trimclip}
\usepackage[voc]{arabxetex}

\setmainfont{Al Qalam Quran Majeed Web} \newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{AlQalamQuranMajeedWeb}

\definecolor{Kalkola}{HTML}{EE171F} % \definecolor{Kalkolab}{HTML}{12AF1F} % %\newcommand{\kal}{\color{Kalkola}}%

\begin{document} {\Huge\begin{arab} \mbox{% \textcolor{Kalkolab}{\clipbox{0 0 {0.7\width} 0}{sub".ha"A}}% \textcolor{Kalkola}{\clipbox{{0.3\width} 0 {0.5\width} 0}{sub".ha"A}}% \textcolor{Kalkolab}{\clipbox{{0.5\width} 0 0 0}{sub".ha"A}}% }

sub".ha"A \end{arab} } \end{document}

Added

Adapting a Tikz solution (also using clipping) from the same linked question is also possible and easier conceptually but more intricate coding-wise, and the resulting Tikzpicture needs to be boxed to flow right-to-left with the text (an \mbox will do), and needs to be lowered vertically by a small amount in relation to the baseline (here, with \raisebox and a negative amount).

tikz version

MWE

\documentclass[12pt]{article}
 \usepackage{xcolor}
%\usepackage{trimclip}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[voc]{arabxetex}

\setmainfont{Al Qalam Quran Majeed Web} \newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{AlQalamQuranMajeedWeb}

\definecolor{Kalkola}{HTML}{EE171F} % \definecolor{Kalkolab}{HTML}{12AF1F} % %\newcommand{\kal}{\color{Kalkola}}%

\newcommand{\Atwo}[3][A]{% \begin{tikzpicture} %place the underlying word \node[inner sep=0pt,outer sep=0pt,text=#2] (a) {#1}; %define the clip rectangle \clip (a.south east) [xshift=-1ex] rectangle (a.north); % place the clipped word above \node[inner sep=0pt,outer sep=0pt,text=#3] {#1}; \end{tikzpicture} }

\begin{document} {\Huge\begin{arab} \fbox{sub".ha"A} {\raisebox{-.482ex}{\fbox{\Atwo[sub".ha"A]{Kalkolab}{Kalkola}}}} sub".ha"A sub".ha"A

sub".ha"A sub".ha"A {\raisebox{-.482ex}{{\Atwo[sub".ha"A]{Kalkolab}{Kalkola}}}}

sub".ha"A \end{arab} } \end{document}

Cicada
  • 10,129