1

I'd like to make some practice worksheets for Devanagari in Outline characters but can't.

I've perused the archive and have not been successful in finding a MWE that works.

Could someone help?

TIA

2
2

Most of the examples that do outlining in XeLaTeX either require contour, tikz, pstricks, or utilizing the \special{} command. Contour doesn't seem to work for Devanagari (at least for me). tikz/pstricks require extra processing/package loading. And most of the examples using \special{} are somewhat cryptic and difficult to understand...

Luckily, I found this answer which makes the process much easier, thanks to @phelype-oleinik

To make this easier for future users, I've taken the outlining (for XeLaTeX) in the link above and combined the use of polyglossia to show examples of outlining Devanagari.

\documentclass{article}

\usepackage{fontspec}

\newfontfamily\hindifont[Scale=MatchUppercase,Script=Devanagari]{Noto Sans Devanagari}

\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguages{hindi}


\usepackage{xcolor}

%SEE: https://tex.stackexchange.com/a/421980/78866
%for explanation and usage

\def\rgbtoarray#1,#2,#3\null{[#1 #2 #3]}%
\def\csvtoarray#1{%
    \expandafter\rgbtoarray#1\null%
}%
\newcommand{\extractrgb}[2]{%
    \extractcolorspecs{#1}{\model}{\mycolor}%
    \convertcolorspec{\model}{\mycolor}{rgb}{\printcol}%
    \edef#2{\printcol}%
}%
%\fillstroke{<fill color>}{<contour color>}{<stroke width>}{<text>}
\newcommand*{\fillstroke}[4]{%
    \extractrgb{#1}{\colorvector}%
    \extractrgb{#2}{\strokevector}%
    \special{pdf:bcolor \csvtoarray{\colorvector} \csvtoarray{\strokevector}}%
    \special{pdf:literal direct #3 w 2 Tr}%
    #4%
    \special{pdf:ecolor}%
    \special{pdf:literal direct 0 Tr}%
}%


\begin{document}

%Example of default
\foreignlanguage{hindi}{चीनी} (cheenee)

%Black text, yellow outline, 0.5 (outline) thickness
\fillstroke{black}{yellow}{0.5}{\Huge \foreignlanguage{hindi}{चीनी}}%

%White text, black outline, 0.5 (outline) thickness
\fillstroke{white}{black}{0.5}{\Huge \foreignlanguage{hindi}{चीनी}}%

%Black text, red outline, 0.75 (outline) thickness
\fillstroke{black}{red}{0.75}{\Huge \foreignlanguage{hindi}{चीनी}}%

%Red text, green outline, 0.25 (outline) thickness
\fillstroke{red}{green}{0.25}{\Huge \foreignlanguage{hindi}{चीनी}}%

%Blue text, gray outline, 1.5 (outline) thickness
\fillstroke{blue}{gray}{1.5}{\Huge \foreignlanguage{hindi}{चीनी}}%

\end{document}

Examples of outlining Devanagari in XeLaTeX

EDIT: I'm using Noto Sans Devanagari in this example. You should be able to replace this font with whatever font you are using already. No other changes should be necessary.

0
2

Outlining with contour in xelatex can be done by not using the outline option. Paradox! A thin-enough contour can appear as an outline -

outline

here, detail of yellow outline with some blue shadowtext as well.

examples

Visual artefacts in that last example are a result of the image capture process, not the PDF viewer:

dark outline

MWE

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{fontspec}
\setmainfont{Noto Serif}[Scale=3]
\usepackage{contour}
\usepackage{shadowtext}

\newcommand\sampletext{कूल्बनन}
\newcommand\sampletextb{कूल्बनन}
\newcommand\sampletextc{कूल्बनन}
\newcommand\ftcname{Noto Serif Devanagari}
\newfontface\ftc{\ftcname}[Scale=2,Script=Devanagari]

\begin{document}
\contourlength{1.4pt}
\shadowcolor{blue}
\shadowoffsetx{1.52pt}
\shadowoffsety{1.52pt}
\Huge
\shadowtext{%
\contour[32]{yellow}{%
\ftc\sampletext
}%
}%

\bigskip\medskip

\contourlength{0.4pt}
\color{yellow}
\shadowcolor{blue}
\shadowoffsetx{0.52pt}
\shadowoffsety{0.52pt}
\Huge
\shadowtext{%
\contour[24]{red}{%
\ftc\sampletextb
}%
}%

\bigskip\medskip

\contourlength{0.8pt}
\color{Magenta}
\shadowcolor{blue!40}
\shadowoffsetx{4.52pt}
\shadowoffsety{2.52pt}
\Huge
\shadowtext{%
\contour[24]{red}{%
\ftc\sampletextc
}%
}%

\bigskip\medskip

\contourlength{1.2pt}
\color{White}
\shadowcolor{blue!20}
\shadowoffsetx{2.12pt}
\shadowoffsety{1.52pt}
\Huge
\shadowtext{%
\contour[14]{red}{%
\ftc\sampletextc
}%
}%

\bigskip\medskip

\contourlength{1.2pt}
\color{White}
\shadowcolor{blue!20}
\shadowoffsetx{2.12pt}
\shadowoffsety{1.52pt}
\Huge
\shadowtext{%
\contour[1]{red}{%
\ftc\sampletextc
}%
}%

\bigskip\medskip

\contourlength{2.2pt}
\color{green!15}
\shadowcolor{blue!20}
\shadowoffsetx{2.12pt}
\shadowoffsety{1.52pt}
\Huge
\shadowtext{%
\contour[1]{black!12}{%
\ftc\sampletextc
}%
}%

\bigskip\medskip

\contourlength{0.6pt}
\color{green!15}
\shadowcolor{blue!20}
\shadowoffsetx{2.12pt}
\shadowoffsety{1.52pt}
\Huge
\shadowtext{%
\contour[48]{black!80}{%
\ftc\sampletextc
}%
}%

contour uses ps commands in its driver .cnt files but, since it is from 2004, it hasn't been set up (yet) to detect xelatex and assign the appropriate driver to do "real" outlines with that engine. It should be straightforward enough to add the \specials in, though.


Edited to add:

For outline mode in contour package to work under xelatex, four changes are required --

Contour

The purpose of the contour package (last updated in 2004) is to make text more legible when printed on a variegated background such as an image or graph. It does this by overlapping (\rlap) copies of the text onto itself, slightly offset by a small factor, for a distance defined by \contourlength{}. A consequence is that, for small values of \contourlength{}, say 0.6pt, the contouring effect looks like an outline of the text.

There are two ways it does the contouring or halo effect: the default method, using cos and sin smoothed over a number of iterations ('copies') to calculate the text offset (used by \hskip and \raisebox); or, alternatively, the outline method (specified by the outline package option), relying on low-level driver-specific commands to shift the text (by a factor of 0.99626400996) and deal with the colours. For outline mode, there is nothing for xelatex ('copies' mode in xelatex works OK).

There are several drivers defined in corresponding control files: dvips.cnt, which issues postscript commands via \special{}: \special{ps: gsave newpath...; dvipsone.cnt, which also does postscript: \special{ps: gsave currentpoint newpath...; pdftex.cnt, which does pdfliterals:

    \pdfliteral{%
      q
      1 j
      1 J
      1 Tr
      \strip@pt\con@length\space w
    }%
    \rlap{#2}%
    \pdfliteral{%
      Q
    }%

and vtex.cnt, which does another sort of postscript: \special{pS: save newpath....

A config file, contour.cfg, takes care of detecting which driver should be used when outline mode is active.

So, to make contour's outline mode work under xelatex requires the following:

(1) Define a new driver

Copy pdftex.cnt and rename it, say, xdvipdfmx.cnt. We'll use the same pdf operators.

Change \pdfliteral{% to \special{pdf:literal direct, so that we have:

    \special{pdf:literal direct q 1 j 1 J 2 Tr \strip@pt\con@length\space w}
    \rlap{#2}%
    \special{pdf:literal direct Q}%

Acknowledgement: Outlined characters

(2) Add xetex detection to the existing tests in contour.cfg:

Insert

  % check xetex
  \@ifundefined{XeTeXversion}{}{%
      \chardef\x=3 % <========== setting value to next available value
    }%

and amend the internal-option setting to include a new xetex option in the case statement:

\ifcase\x
  % default case
  \ExecuteOptions{dvips}%
\or
  % pdfTeX is running in pdf mode
  \ExecuteOptions{pdftex}%
\or
  % VTeX is running
  \ExecuteOptions{vtex}%
\or
  % xetex
  \ExecuteOptions{xetex}%<============= 3rd
\else
  % VTeX is running
  \ExecuteOptions{vtex}%
\fi

(3) In contour.sty, one line needs to be added: declare that new xetex option and what it does (sets the driver name to xdvipdfmx.cnt).

\DeclareOption{xetex}{\def\con@driver{xdvipdfmx.cnt}} %<=============

Full files in case I've missed anything:

xdvipdfmx.cnt:

%%
%% This is file `pdftex.cnt',xxx
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% contour.dtx  (with options: `drv,pdftex')
%% 
%%   contour package driver file
%% 
%%   Copyright  2004 Harald Harders
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de
%% 
\ProvidesFile{dvipdfmx.cnt}
  [2004/11/18  v2.14  Print contoured text (HH, MH); modified 2019-11-15 for xelatex]
\newcommand*\@contour@outline[2]{%
  \begingroup
    \setlength\con@length{2\con@length}%
    \setlength\con@length{0.99626400996\con@length}%
    \color{#1}%
    \con@coloroff%===
%    \pdfliteral{%
%      q
%      1 j
%      1 J
%      1 Tr
%      \strip@pt\con@length\space w
%    }%
%%      - Tr %text rendering mode: 
%               0 fill text
%               1 stroke text
%               2 fill, then stroke text
%               3 neither fill nor stroke (invisible)
%               4 fill, add to clipping path
%               5 stroke, add to clipping path
%%      - w % width in big points
%%      - - - RG %rgb stroking colour 0-1 0-1 0-1
%%      - - - rg %rgb non-stroking colour 0-1 0-1 0-1
%%      - j %line join style
%%          0 miter (like picture frame)
%%          1 round (like arc, pie-slice)
%%          2 bevel 
%%      - J %line cap style 
%%          0   butt
%%          1   round
%%          2   projecting square
%%          
%%      - w %line width
%%      q %save current graphics state
%%      Q %restore graphics state
    \special{pdf:literal direct q 1 j 1 J 2 Tr      \strip@pt\con@length\space w}
    \rlap{#2}%
%    \pdfliteral{%
%      Q
%    }%
    \special{pdf:literal direct Q}%
  \endgroup
  \mbox{#2}%
}
\endinput
%%
%% End of file `xdvipdfmx.cnt'.

contour.cfg:

%%
%% This is file `contour.cfg',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% contour.dtx  (with options: `cfgfile')
%% -
%%   contour package configuration file
%% 
%%   Copyright  2004 Harald Harders
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de
%% 
\ProvidesFile{contour.cfg}
  [2004/11/18  v2.14  Print contoured text (HH, MH); modified 2019-11-16 for xetex ]
 % Select an appropriate default driver
\begingroup
  \chardef\x=0 %
  % check pdftex
  \@ifundefined{pdfoutput}{}{%
    \ifcase\pdfoutput
    \else
      \chardef\x=1 %
    \fi
  }%
  % check VTeX
  \@ifundefined{OpMode}{}{%
    \chardef\x=2 %
  }%
  % check xetex
  \@ifundefined{XeTeXversion}{}{%
      \chardef\x=3 % 
    }%
%%  \ifxetex %requires ifxetex package
%%      \chardef\x=3 %
%%  \fi
\expandafter\endgroup
\ifcase\x
  % default case
  \ExecuteOptions{dvips}%
\or
  % pdfTeX is running in pdf mode
  \ExecuteOptions{pdftex}%
\or
  % VTeX is running
  \ExecuteOptions{vtex}%
\or
  % xetex
  \ExecuteOptions{xetex}%
\else
  % VTeX is running
  \ExecuteOptions{vtex}%
\fi
\endinput
%%
%% End of file `contour.cfg'.

contour.sty:

%%
%% This is file `contour.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% contour.dtx  (with options: `package')
%% 
%%   contour package
%% 
%%   Copyright  1999--2004 Harald Harders, Morten H�gholm
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de, moho01ab@student.cbs.dk
%% 
%% 
%%   Original: Richard Pfeiffer (richard.pfeiffer@t-online.de)
%%   Totally rewritten end extended.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{contour}
  [2004/11/18  v2.14  Print contoured text (HH, MH); modified 2019-11-16 for xetex]
\RequirePackage{xcolor}%<=========== changed from color to xcolor
\RequirePackage{trig}
%%\RequirePackage{ifxetex}%xxx for \ifxetex command
\def\con@coloroff{%
  \def\@undeclaredcolor[##1]##2{}%
  \def\@declaredcolor##1{}%
}
\newcommand*\con@put[3]{%
  \rlap{\hskip#1\raisebox{#2}[0pt]{#3}}%
}
\newcommand*\contourlength[1]{\def\con@base@length{#1}}
\contourlength{0.03em}
\newcommand*\contournumber[1]{\def\con@default@copies{#1}}
\contournumber{16}
\newlength{\con@length}
\newcommand*\con@define@copyangles[1]{%
  \edef\con@tempa{auto}%
  \edef\con@tempb{#1}%
  \ifx\con@tempa\con@tempb
    \expandafter\ifdim\f@size pt<15pt\relax
      \edef\con@tempb{16}%
    \else
      \expandafter\ifdim\f@size pt<25pt\relax
        \edef\con@tempb{32}%
      \else
        \expandafter\ifdim\f@size pt<50pt\relax
          \edef\con@tempb{60}%
        \else
          \edef\con@tempb{120}%
        \fi
      \fi
    \fi
  \fi
  \@tempcnta=\con@tempb\relax
  \@ifundefined{con@\number\@tempcnta @copies}{%
    \global\@namedef{con@\number\@tempcnta @copies}{}%
    \@tempdima=360\p@
    \divide\@tempdima by \@tempcnta
    \@tempdimb=\z@
    \@tempcntb=\z@
    \loop
      \ifnum\@tempcntb<\@tempcnta
        \edef\con@temp@fdim{\strip@pt\@tempdimb}%
        \CalculateSin{\con@temp@fdim}%
        \CalculateCos{\con@temp@fdim}%
        \advance\@tempcntb \@ne
        \advance\@tempdimb \@tempdima\relax
    \repeat
  }{}%
  \let\con@tempa\@undefined
  \let\con@tempb\@undefined
}
\newcommand*\contour{\@ifstar{\@contour[32]}{\@contour}}
\newcommand*\@contour[3][\con@default@copies]{%
  \ifvmode
    \leavevmode
  \fi
  \setlength\con@length{\con@base@length}%
  \ifcon@outline
    \typeout{contour: Using real outline for `#3'\on@line.}%
    \@contour@outline{#2}{#3}%
  \else
    \begingroup
      \con@define@copyangles{#1}%
      \typeout{contour: Using \the\@tempcnta\space copies for `#3'\on@line.}%
      \@tempdima=360\p@
      \divide\@tempdima by \@tempcnta\relax
      \@tempdimb=\z@
      \@tempcntb=\z@
      \color{#2}%
      \con@coloroff
      \loop
        \ifnum\@tempcntb<\@tempcnta\relax
          \edef\con@temp@fdim{\strip@pt\@tempdimb}%
          \con@put
            {\UseSin{\con@temp@fdim}\con@length}%
            {\UseCos{\con@temp@fdim}\con@length}%
            {#3}%
          \advance\@tempcntb \@ne\relax
          \advance\@tempdimb\@tempdima\relax
      \repeat
    \endgroup
    \mbox{#3}%
  \fi
}
\providecommand*\con@driver{\@empty}
\newif\ifcon@outline
\DeclareOption{auto}{\contournumber{auto}}
\DeclareOption{dvips}{\def\con@driver{dvips.cnt}}
\DeclareOption{xdvi}{\ExecuteOptions{dvips}}
\DeclareOption{pdftex}{\def\con@driver{pdftex.cnt}}
\DeclareOption{xetex}{\def\con@driver{xdvipdfmx.cnt}} %<=============
\DeclareOption{vtex}{\def\con@driver{vtex.cnt}}
\DeclareOption{dvipsone}{\def\con@driver{dvipsone.cnt}}
\DeclareOption{outline}{\con@outlinetrue}
\DeclareOption{copies}{\con@outlinefalse}
\InputIfFileExists{contour.cfg}{%
  \typeout{Loading configuration file `contour.cfg'.}%
}{%
  \typeout{No configuration file `contour.cfg' found.}%
}
\ProcessOptions\relax
\expandafter\ifx\con@driver\@empty
  \ifcon@outline
    \PackageError{contour}{Chosen package option `outline' but no
      driver defined}{Leave out the `outline' option or define a driver}%
  \else
    \PackageWarning{contour}{No driver defined (which does not matter
      when using copies)}%
  \fi
\else
  \InputIfFileExists{\con@driver}{%
    \typeout{contour: Using driver file `\con@driver'.}%
  }{%
    \PackageError{contour}{Driver file `\con@driver' does not exist}{}%
  }%
\fi
\endinput
%%
%% End of file `contour.sty'.

MWE

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{fontspec}
\usepackage[outline]{contour}

\newcommand\sampletextc{कूल्बनन}
\newcommand\ftcname{Noto Serif Devanagari}
\newfontface\ftc{\ftcname}[Scale=2,Script=Devanagari]

\begin{document}

\contourlength{1pt}
\color{white}
\Huge
\contour{black}{%
\ftc\sampletextc
}%
\end{document}

End result:

outline mode:

contours outline method with xelatex

For comparison, the copies mode at the same settings:

contour copies mode with xelatex

Perhaps there might be a way to officially update the package, if the outline mode under xelatex is deemed useful enough (and later, when lualatex's font-shaping engine can shape complex non-latin syllables correctly, also under lualatex). As a fallback, kerning (on an overlap) can always be done manually.

Note

There is some confusion about the meaning of "outline" when contour package uses the term: outline means "widen an outline font by using the w PDF operator so as to produce the underlying text to rlap onto the unshifted text".

It does not mean "colour the outer edge of the glyph shape".

In both of these examples below, the blue-coloured text is underneath and is wider than the yellow-coloured text on top. Both of the examples are produced using the outline option. It's just that the "halo" (the blue part) is quite narrow in the second example, and gives the illusion that it is the yellow text that has been converted to an "outline".

is it outlined text

Commenting out the \rlap command shows how the "outlining" is done:

the effect is done by overlapping text


Edited to further add:

Looks like the PDF operators can handle stroke width, stroke colour, and fill colour. No need for overlapping anything.

Breaking away somewhat from the spirit of the contour package (which is to add a background halo following the contours of the glyphs) -

Added a new option xeoutline which does "true" outlines under xelatex (and no need for overlapping), using PDF stroke and fill operations, with new commands \cfillrgb{}{}{} defining the three-channel RGB fill colour (values go from 0-1), \cstrokergb{}{}{} defining the RGB stroke colour, and \cstrokewidth{} setting the stroke width (in big points, apparently). The first parameter of \contour becomes superfluous under xeoutline option and can be left empty (or non-empty, it doesn't go anywhere).

e.g.

\cfillrgb{1}{0.75}{1}%purple-y mauve
\cstrokergb{.3}{0.85}{0.5}%dark greeny
\cstrokewidth{1.6}%big points: thick line
\contour{}{%
\ftc\sampletextc
}%

produces

thich-line output

There is a new xdvipdfmx2.cnt file

%%
%% This is file `pdftex.cnt',xxx
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% contour.dtx  (with options: `drv,pdftex')
%% 
%%   contour package driver file
%% 
%%   Copyright  2004 Harald Harders
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de
%% 
\ProvidesFile{dvipdfmx2.cnt}
  [2004/11/18  v2.14  Print contoured text (HH, MH); modified 2019-11-17 for xelatex and `real' outlines]
\newcommand*\@contour@outline[2]{%
  \begingroup
%    \setlength\con@length{2\con@length}%
%    \setlength\con@length{0.99626400996\con@length}%
%    \color{#1}%
%    \con@coloroff%===
%    \pdfliteral{%
%      q
%      1 j
%      1 J
%      1 Tr
%      \strip@pt\con@length\space w
%    }%
%%      - Tr %text rendering mode: 
%               0 fill text
%               1 stroke text
%               2 fill, then stroke text
%               3 neither fill nor stroke (invisible)
%               4 fill, add to clipping path
%               5 stroke, add to clipping path
%%      - w % width in big points
%%      - - - RG %rgb stroking colour 0-1 0-1 0-1
%%      - - - rg %rgb non-stroking colour 0-1 0-1 0-1
%%      - j %line join style
%%          0 miter (like picture frame)
%%          1 round (like arc, pie-slice)
%%          2 bevel 
%%      - J %line cap style 
%%          0   butt
%%          1   round
%%          2   projecting square
%%          
%%      - w %line width
%%      q %save current graphics state
%%      Q %restore graphics state
    \special{pdf:literal direct q 1 j 1 J 2 Tr %\strip@pt\con@length\space w
    \pdfls\space RG \pdflf\space rg \cswidth\space w 2 Tr}
    {#2}%
%    \pdfliteral{%
%      Q
%    }%
    \special{pdf:literal direct Q}%
  \endgroup
%
}
\endinput
%%
%% End of file `xdvipdfmx2.cnt'.

and a modified contour.sty file

%%
%% This is file `contour.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% contour.dtx  (with options: `package')
%% 
%%   contour package
%% 
%%   Copyright  1999--2004 Harald Harders, Morten H�gholm
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de, moho01ab@student.cbs.dk
%% 
%% 
%%   Original: Richard Pfeiffer (richard.pfeiffer@t-online.de)
%%   Totally rewritten end extended.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{contour}
  [2004/11/18  v2.14  Print contoured text (HH, MH); modified 2019-11-16 for xetex, 2019-11-17 `real' outlines added]
\RequirePackage{xcolor}%<=========== changed from color to xcolor
\RequirePackage{trig}
%%\RequirePackage{ifxetex}%xxx for \ifxetex command
\def\con@coloroff{%
  \def\@undeclaredcolor[##1]##2{}%
  \def\@declaredcolor##1{}%
}
\newcommand*\con@put[3]{%
  \rlap{\hskip#1\raisebox{#2}[0pt]{#3}}%
}
\newcommand*\contourlength[1]{\def\con@base@length{#1}}
\contourlength{0.03em}
\newcommand*\contournumber[1]{\def\con@default@copies{#1}}
\contournumber{16}
\newlength{\con@length}
\newcommand*\con@define@copyangles[1]{%
  \edef\con@tempa{auto}%
  \edef\con@tempb{#1}%
  \ifx\con@tempa\con@tempb
    \expandafter\ifdim\f@size pt<15pt\relax
      \edef\con@tempb{16}%
    \else
      \expandafter\ifdim\f@size pt<25pt\relax
        \edef\con@tempb{32}%
      \else
        \expandafter\ifdim\f@size pt<50pt\relax
          \edef\con@tempb{60}%
        \else
          \edef\con@tempb{120}%
        \fi
      \fi
    \fi
  \fi
  \@tempcnta=\con@tempb\relax
  \@ifundefined{con@\number\@tempcnta @copies}{%
    \global\@namedef{con@\number\@tempcnta @copies}{}%
    \@tempdima=360\p@
    \divide\@tempdima by \@tempcnta
    \@tempdimb=\z@
    \@tempcntb=\z@
    \loop
      \ifnum\@tempcntb<\@tempcnta
        \edef\con@temp@fdim{\strip@pt\@tempdimb}%
        \CalculateSin{\con@temp@fdim}%
        \CalculateCos{\con@temp@fdim}%
        \advance\@tempcntb \@ne
        \advance\@tempdimb \@tempdima\relax
    \repeat
  }{}%
  \let\con@tempa\@undefined
  \let\con@tempb\@undefined
}
\newcommand*\contour{\@ifstar{\@contour[32]}{\@contour}}
\newcommand*\@contour[3][\con@default@copies]{%
  \ifvmode
    \leavevmode
  \fi
  \setlength\con@length{\con@base@length}%
  \ifcon@outline
    \typeout{contour: Using real outline for `#3'\on@line.}%
    \@contour@outline{#2}{#3}%
  \else
    \begingroup
      \con@define@copyangles{#1}%
      \typeout{contour: Using \the\@tempcnta\space copies for `#3'\on@line.}%
      \@tempdima=360\p@
      \divide\@tempdima by \@tempcnta\relax
      \@tempdimb=\z@
      \@tempcntb=\z@
      \color{#2}%
      \con@coloroff
      \loop
        \ifnum\@tempcntb<\@tempcnta\relax
          \edef\con@temp@fdim{\strip@pt\@tempdimb}%
          \con@put
            {\UseSin{\con@temp@fdim}\con@length}%
            {\UseCos{\con@temp@fdim}\con@length}%
            {#3}%
          \advance\@tempcntb \@ne\relax
          \advance\@tempdimb\@tempdima\relax
      \repeat
    \endgroup
    \mbox{#3}%
  \fi
}
\providecommand*\con@driver{\@empty}
\newif\ifcon@outline
\DeclareOption{auto}{\contournumber{auto}}
\DeclareOption{dvips}{\def\con@driver{dvips.cnt}}
\DeclareOption{xdvi}{\ExecuteOptions{dvips}}
\DeclareOption{pdftex}{\def\con@driver{pdftex.cnt}}
\DeclareOption{xetex}{\def\con@driver{xdvipdfmx.cnt}} %<=============
\DeclareOption{vtex}{\def\con@driver{vtex.cnt}}
\DeclareOption{dvipsone}{\def\con@driver{dvipsone.cnt}}
\DeclareOption{outline}{\con@outlinetrue}
\DeclareOption{copies}{\con@outlinefalse}
\DeclareOption{xeoutline}{\con@outlinetrue\def\con@driver{xdvipdfmx2.cnt}} %<============2
\InputIfFileExists{contour.cfg}{%
  \typeout{Loading configuration file `contour.cfg'.}%
}{%
  \typeout{No configuration file `contour.cfg' found.}%
}
\ProcessOptions\relax
\expandafter\ifx\con@driver\@empty
  \ifcon@outline
    \PackageError{contour}{Chosen package option `outline' but no
      driver defined}{Leave out the `outline' option or define a driver}%
  \else
    \PackageWarning{contour}{No driver defined (which does not matter
      when using copies)}%
  \fi
\else
  \InputIfFileExists{\con@driver}{%
    \typeout{contour: Using driver file `\con@driver'.}%
  }{%
    \PackageError{contour}{Driver file `\con@driver' does not exist}{}%
  }%
\fi
%<============2: new adds
%colour: stroke: set:
\newcommand\cstrokergb[3]{\edef\pdfls{#1\space #2\space  #3\space }}
\cstrokergb{1}{0}{0}%default = red
%colour: fill: set:
\newcommand\cfillrgb[3]{\edef\pdflf{#1\space #2\space  #3\space }}
\cfillrgb{0}{1}{1}%default = cyan
%stroke: width: set
\newcommand\cstrokewidth[1]{\edef\cswidth{#1\space}}
\cstrokewidth{0.3}%default (unit=big points?)
%<============2 end new adds
\endinput
%%
%% End of file `contour.sty'.

No change in the contour.cfg file.

MWE

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{fontspec}
\usepackage[xeoutline]{contour}

\newcommand\sampletextc{कूल्बनन}
\newcommand\ftcname{Noto Serif Devanagari}
\newfontface\ftc{\ftcname}[Scale=2,Script=Devanagari]

\begin{document}

\Huge

\contour{}{%
\ftc\sampletextc
}%
\bigskip

%\contourlength{8.6pt}
%\color{yellow}
\cfillrgb{1}{1}{0}%yellow
\cstrokergb{0}{0}{1}%blue
\cstrokewidth{3.6}%big points
\contour{}{%
\ftc\sampletextc
}%
\bigskip

\cfillrgb{1}{1}{1}%white
\cstrokergb{0}{0}{0}%black
\cstrokewidth{0.6}%big points
\contour{}{%
\ftc\sampletextc
}%
\bigskip

\cfillrgb{.95}{.95}{.95}%off-white
\cstrokergb{.1}{.1}{.1}%off-black
\cstrokewidth{0.6}%big points
\contour{}{%
\ftc\sampletextc
}%
\bigskip

\cfillrgb{1}{0.75}{1}%purple-y mauve
\cstrokergb{.3}{0.85}{0.5}%dark greeny
\cstrokewidth{1.6}%big points: thick line
\contour{}{%
\ftc\sampletextc
}%
\bigskip


\end{document}

output from MWE

Outside the xeoutline option, normal contour functions continue as usual (plus contour's overlapping outline option now works under xelatex).

1
  • And it is only now that I begin to understand @PhelypeOleinik 's workaround code at tex.stackexchange.com/a/421980/78866 , which is much more compact and elegant (and uses xcolor's colour conversion macros as well, like the first answer too).
    – Cicada
    Nov 17 '19 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.