为什么不能沿曲线路径勾勒文字轮廓?

为什么不能沿曲线路径勾勒文字轮廓?

我想使用带有白色轮廓的字体但似乎不起作用。

\usepackage{color}
\usepackage[outline]{contour}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}
\begin{tikzpicture}
    \font\f=cmr17 at20pt;
    \node (inicio) at (-3.9cm, -0.95cm) {};
    \node (fin) at (4.1cm,-0.75cm) {};   
    \draw[decoration={text along path,
           text={|\f|\contour{red}|This is a long sample text|||},
           text align={center}},decorate]  (inicio) to [out=-2,in=520]  (fin);
\end{tikzpicture}
\end{document}

有什么帮助吗?

答案1

您可以使用text effects along path装饰将命令应用\contour到每个角色。

在此处输入图片描述

\documentclass{standalone}
\usepackage{color}
\usepackage[outline]{contour}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
  \def\mycontour#1{\contour{red}#1}
  \node (inicio) at (-3.9cm, -0.95cm) {};
  \node (fin) at (4.1cm,-0.75cm) {};   
  \draw[
    decoration={text effects along path,
      text={This is a long sample text},
      text align=center,
      text effects/.cd,
      text along path,
      every character/.style={font=\huge,character command=\mycontour}
    },decorate
  ]  (inicio) to [out=-2,in=160]  (fin);
\end{tikzpicture}
\end{document}

编辑:这是一个更好的版本。

在此处输入图片描述

\documentclass[tikz]{standalone}
\usepackage{lmodern}
\usepackage[outline]{contour}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
  \def\mycontour#1{\textcolor{white}{\contour{red}{#1}}}
  \node (inicio) at (-3.9cm, -0.95cm) {};
  \node (fin) at (4.1cm,-0.75cm) {};   
  \draw[
  decoration={text effects along path,
    text={This is a long sample text},
    text align=center,
    text effects/.cd,
    text along path, scale text to path,
    characters={font=\Huge,character command=\mycontour},
  },decorate,
  ]  (inicio) to [out=-2,in=160]  (fin);
\end{tikzpicture}
\end{document}

相关内容