TikZ:使用 pdfrender 向节点文本添加额外空间

TikZ:使用 pdfrender 向节点文本添加额外空间

在下图中,当我使用\prints我在序言中定义的宏(根据 TeXstudio 为第 14 行)时,添加了很多额外的空间(相对于它的真实大小,大约为 4cm x 3cm),如第一张图所示;此宏使用pdfrender包的宏\textpdfrender;另外,由于某种原因,atril文档查看器将 Q 尾部的一部分显示为白色,而 TeXstudio 的内部查看器将其正确地呈现为蓝色。与第二张图像相比,其中在注释后的行中(根据 TeXstudio 为第 40 行)\prints[<colour>]{<letter>}被替换为。代码:\textcolor{<colour>}{<letter>}%%%%%%%%%%%%%%%%%%%%%%%%%TEXT CODE!!!

\documentclass[tikz]{standalone}

\usepackage[T1]{fontenc}
\usepackage{pdfrender}

\usetikzlibrary{
    positioning, 
    backgrounds,
%   calc
}

%%%%%%%%%DEF \prints MACRO
\newcommand{\prints}[2][black]{
    \textpdfrender{%
        TextRenderingMode=FillStroke,%
        FillColor=#1,%
        LineWidth=0.1pt,%
    }{#2}%
}
\setlength{\parindent}{0pt}
\begin{document}

\begin{tikzpicture}
    %%%FONT SIZE DETS. PICTURE SIZE
    \newdimen\ttext
    \ttext = 80pt
    \fontsize{\ttext}{22}\fontfamily{trjn}\selectfont\par
    %%%%%/FONTSIZE.

    %%%%QED NODE
    \node[
        inner ysep = 1.5pt, 
        inner xsep = -1.7pt,
        outer sep = 0pt, 
%       draw, 
%       ultra thin
        ] (q) at (0,0) 
    %%%%%%%%%%%%%%%%%%%%%%%%%TEXT CODE!!!
    {
        \raisebox{-0.22em}{\prints[cyan!80!black]{Q}} 
        \kern -1.05ex \raisebox{0.22em}{\prints[red!80!black]{E}} 
        \kern -1.1ex\hbox{\prints[green!80!black]{D}} 
    };
    %%%%%%%%%%%%%%/QED

    %%%EXTRA NODE FOR MORE SPACE
    \node [below = 0.18\ttext of current bounding box.south, inner sep = 0pt, outer sep = 0pt, anchor = south] (a) {};

    %%%BG RECTANGLE
    \begin{scope}[
        on background layer, 
        every path/.style = {
        line width = 0.25pt, 
        opacity = 0.5
    }
    ]
    \fill[
    opacity = 1,
    top color = gray, 
    bottom color = gray!5,
    ] (current bounding box.south west) rectangle (current bounding box.north east);
    \end{scope}
\end{tikzpicture}

\end{document}

我真的很想得到第二张图片,但要像第一张图片一样有轮廓的字母;我意识到我可以通过在每个字母上留出足够的负空间来获得第二张图片,但我更想知道为什么pdfrender要添加这个空间以及如何删除它(如果可能的话)。我也尝试使用该contour包,但我得到了第三张图片(修改命令打印的份数后\contour;图像完成了 7 张,但我对结果不满意,特别是在 E 的手臂上)。谢谢!!

使用 <code>\textpdfrender</code> 没有 <code>\textpdfrender</code> 在此处输入图片描述

答案1

基本上所有这些都来自虚假空间(与 Ti 无关Z 本身)。讽刺的是,这种构造要求 Q 和 E 之间恰好有一个空格,E 和 D 之间也恰好有一个空格。我%在各个地方添加了空格以删除这些空格,例如在节点的开头。

\documentclass[tikz]{standalone}

\usepackage[T1]{fontenc}
\usepackage{pdfrender}

\usetikzlibrary{
    positioning, 
    backgrounds,
%   calc
}

%%%%%%%%%DEF \prints MACRO
\newcommand{\prints}[2][black]{%
    \textpdfrender{%
        TextRenderingMode=FillStroke,%
        FillColor=#1,%
        LineWidth=0.1pt,%
    }{#2}%
}
\setlength{\parindent}{0pt}
\newdimen\ttext
\ttext=80pt%
\begin{document}

\begin{tikzpicture}
    %%%FONT SIZE DETS. PICTURE SIZE
%     \fontsize{\ttext}{22}\fontfamily{trjn}\selectfont%\par
    %%%%%/FONTSIZE.

    %%%%QED NODE
    \node[
        inner ysep = 1.5pt, 
        inner xsep = -1.7pt,
        outer sep = 0pt, 
%       draw, 
       font=\fontsize{\ttext}{22}\fontfamily{trjn}\selectfont,
%       ultra thin
        ] (q) at (0,0) 
    %%%%%%%%%%%%%%%%%%%%%%%%%TEXT CODE!!!
    {%
        \raisebox{-0.22em}{\prints[cyan!80!black]{Q}} %<- need one space 
        \kern -1.05ex \raisebox{0.22em}{\prints[red!80!black]{E}} % 
        \kern -1.1ex\hbox{\prints[green!80!black]{D}}%
    };
    %%%%%%%%%%%%%%/QED

    %%%EXTRA NODE FOR MORE SPACE
    \node [below = 0.18\ttext of current bounding box.south, inner sep = 0pt, outer sep = 0pt, anchor = south] (a) {};

    %%%BG RECTANGLE
    \begin{scope}[
        on background layer, 
        every path/.style = {
        line width = 0.25pt, 
        opacity = 0.5
    }
    ]
    \fill[
    opacity = 1,
    top color = gray, 
    bottom color = gray!5,
    ] (current bounding box.south west) rectangle (current bounding box.north east);
    \end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容