文字构成字母的路径

文字构成字母的路径

文本如何制作字母的路径,例如字母“S”? 而不是像下面的代码那样画一个圆圈:

\documentclass[landscape]{article}
%\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[absolute,overlay]{textpos}
\usepackage{listings}
\usepackage{xcolor}

\usepackage{tikz}
\usepgfmodule{decorations}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations.text}

\begin{document}
    \DeclareFixedFont{\pb}{T1}{pbk}{b}{n}{5cm}
    
    \mbox{}
    \begin{textblock*}{200mm}[0.2,0.5](67mm,33mm)
        
        \catcode`\|12
        \begin{tikzpicture}
            %\draw [help lines] (4,4)grid (0,2);
            \fill [draw=none,fill=none,
            postaction={decorate,decoration={raise=8pt,text along path,
                    text=around and around and around and around we go we go we go we go we go we go we go we go we go we go we go}}]
            (0,1) arc (180:-180:3.5cm and 2.4cm);
        \end{tikzpicture}
        
    \end{textblock*}
\end{document}

答案1

代码有点旧了,所以不能保证健壮。它需要一些旧文件TeX-SX Launchpad 项目

  • pgflibraryshapes.letters.dtx下载后运行tex pgflibraryshapes.letters.dtx生成所需文件
  • stikz-normal-paths.tex加载 STIX 字体的路径

它似乎只适用于pdflatex(不适用于lualatex),可能是因为某些文件中的某些编码选择不正确。因此修复它应该不难。

\documentclass{article}
%\url{https://tex.stackexchange.com/q/614684/86}
\pagestyle{empty}
\thispagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{
  shapes.letters,
  decorations.text,
}

\pgfmathsetmacro{\emcm}{1em/1cm}
\pgfkeys{
  /pgf/letter/.cd,
%  load font={stikz}{italic},
  load font={stikz}{normal},
  size=10,
  load encoding=char,
  every letter/.append style={
    fill,
  },
  sentence width=.9\textwidth,
}

\begin{document}
\begin{tikzpicture}
\node[letter=S,
    decorate,
    decoration={
      raise=8pt,
      text along path,
      text={Round and round the garden
        Like a teddy bear;
        One step, two step,
        Tickle you under there!
      Round and round the garden
        Like a teddy bear;
        One step, two step,
        Tickle you under there!
      Round and round the garden
        Like a teddy bear;
        One step, two step,
        Tickle you under there!}
    }
] {};
\end{tikzpicture}
\end{document}

字母 S 周围的文字

相关内容