我想制作一些用轮廓字符书写的天城文练习表,但是做不到。
我仔细查看了档案,但未能找到可行的 MWE。
有人可以帮忙吗?
短暂性脑缺血发作
答案1
XeLaTeX 中大多数进行轮廓绘制的示例要么需要contour
、tikz
、pstricks
,要么使用\special{}
命令。Contour 似乎不适用于 Devanagari(至少对我来说)。/ tikz
需要pstricks
额外的处理/包加载。而且大多数使用的示例\special{}
都有些神秘且难以理解...
幸运的是,我找到了这个答案使这个过程变得更容易,感谢@phelype-oleinik
为了让未来的用户更容易使用,我采用了上面链接中的大纲(针对 XeLaTeX),并结合使用来polyglossia
展示大纲天城文的示例。
\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}
编辑:我在此示例中使用的是 Noto Sans Devanagari。您应该能够用您已经使用的任何字体替换此字体。无需进行其他更改。
答案2
contour
不使用选项即可在 xelatex 中勾勒轮廓outline
。矛盾!足够细的轮廓可以显示为轮廓 -
这里,黄色轮廓的细节中shadowtext
也带有一些蓝色。
最后一个例子中的视觉伪影是图像捕获过程的结果,而不是 PDF 查看器的结果:
平均能量损失
\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
在其驱动程序文件中使用 ps 命令.cnt
,但由于它是 2004 年的,因此尚未设置检测 xelatex 并分配适当的驱动程序来使用该引擎执行“真实”轮廓。\special
不过,添加 s 应该很简单。
编辑添加:
为了使包中的大纲模式contour
在 xelatex 下工作,需要进行四处更改 -
轮廓
该软件包(上次更新于 2004 年)的目的contour
是使文本在杂色背景(如图像或图形)上打印时更清晰易读。它通过将\rlap
文本副本重叠()到其自身上来实现此目的,并以小倍数稍微偏移,距离定义为\contourlength{}
。结果是,对于较小的值\contourlength{}
,例如 0.6pt,轮廓效果看起来像文本的轮廓。
有两种方法可以实现轮廓或光晕效果:默认方法,使用余弦和罪通过多次迭代(“副本”)来平滑计算文本偏移量(由\hskip
和使用\raisebox
);或者,使用轮廓方法(由outline
包选项指定),依靠低级驱动程序特定的命令来移动文本(倍数为 0.99626400996)并处理颜色。对于轮廓模式,xelatex 没有任何内容(xelatex 中的“副本”模式可以正常工作)。
相应的控制文件中定义了几个驱动程序:dvips.cnt
,它通过以下方式发出 postscript 命令\special{}
:\special{ps: gsave newpath...
;
dvipsone.cnt
,它还执行 postscript:\special{ps: gsave currentpoint newpath...
;pdftex.cnt
,它执行 pdfliterals:
\pdfliteral{%
q
1 j
1 J
1 Tr
\strip@pt\con@length\space w
}%
\rlap{#2}%
\pdfliteral{%
Q
}%
和vtex.cnt
,这又起到了另一种附言的作用:\special{pS: save newpath...
。
配置文件contour.cfg
负责检测在outline
模式处于活动状态时应使用哪个驱动程序。
因此,要使 的contour
模式outline
在 xelatex 下工作需要以下内容:
(1)定义新的驱动程序
复制pdftex.cnt
并重命名,例如xdvipdfmx.cnt
。我们将使用相同的 pdf 操作符。
改为,这样我们得到\pdfliteral{%
:\special{pdf:literal direct
\special{pdf:literal direct q 1 j 1 J 2 Tr \strip@pt\con@length\space w}
\rlap{#2}%
\special{pdf:literal direct Q}%
致谢:轮廓字符
(2)在现有测试中添加 xetex 检测contour.cfg
:
插入
% check xetex
\@ifundefined{XeTeXversion}{}{%
\chardef\x=3 % <========== setting value to next available value
}%
并修改内部选项设置以xetex
在 case 语句中包含一个新选项:
\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)在 中contour.sty
,需要添加一行:声明新xetex
选项及其功能(将驱动程序名称设置为xdvipdfmx.cnt
)。
\DeclareOption{xetex}{\def\con@driver{xdvipdfmx.cnt}} %<=============
完整文件以防我遗漏任何内容:
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.
%%
%% [email protected]
%%
\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.
%%
%% [email protected]
%%
\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.
%%
%% [email protected], [email protected]
%%
%%
%% Original: Richard Pfeiffer ([email protected])
%% 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'.
平均能量损失
\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}
最终结果:
轮廓模式:
为了进行比较,相同设置的复印模式:
如果 xelatex 下的轮廓模式被认为足够有用(以及稍后,当 lualatex 的字体塑造引擎能够正确塑造复杂的非拉丁音节时,在 lualatex 下也是如此),也许可以正式更新该软件包。作为后备,字距调整(在重叠处)始终可以手动完成。
笔记
contour
当包装使用术语“轮廓”时,人们对其含义存在一些混淆:outline
是指“扩大轮廓字体通过使用w
PDF 运算符,从而将底层文本生成到rlap
未移位的文本上”。
它并不意味着“为字形的外边缘着色”。
在下面的两个例子中,蓝色文本位于下方,并且比上方的黄色文本更宽。这两个例子都是使用该outline
选项生成的。只是第二个例子中的“光晕”(蓝色部分)相当窄,给人一种错觉,好像黄色文本已转换为“轮廓”。
注释掉该\rlap
命令显示了“概述”是如何完成的:
编辑以进一步添加:
看起来 PDF 操作符可以处理描边宽度、描边颜色和填充颜色。无需重叠任何内容。
稍微脱离了contour
包装的精神(即添加一个跟随字形轮廓的背景光环) -
添加了一个新选项xeoutline
,该选项在 xelatex 下可产生“真实”轮廓(无需重叠),使用 PDF 描边和填充操作,新命令 \cfillrgb{}{}{}
定义三通道 RGB 填充颜色(值从 0 到 1),\cstrokergb{}{}{}
定义 RGB 描边颜色,并\cstrokewidth{}
设置描边宽度(显然以大点为单位)。第一个参数\contour
在选项下变得多余xeoutline
,可以留空(或非空,它不会去任何地方)。
例如
\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
}%
生产
有一个新xdvipdfmx2.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.
%%
%% [email protected]
%%
\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'.
以及修改后的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.
%%
%% [email protected], [email protected]
%%
%%
%% Original: Richard Pfeiffer ([email protected])
%% 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'.
文件没有变化contour.cfg
。
平均能量损失
\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}
在该xeoutline
选项之外,正常contour
功能继续照常运行(pluscontour
的重叠outline
选项现在可以在 xelatex 下工作)。