桥接贝塞尔曲线节点文本粗细

桥接贝塞尔曲线节点文本粗细

继续https://tex.stackexchange.com/a/581548,考虑以下代码:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,angles,calc}
%%% Stolen from http://tex.stackexchange.com/a/581548
\makeatletter
\tikzset{bridge/.code args={#1 over #2}{%
 \path[name path=tmp@bridge@path@B] #1;
 \tikzset{name intersections={of=#2 and tmp@bridge@path@B,
    by=tmp@i@0,total=\tmp@i@total}}
 \ifnum\tmp@i@total=0
  \typeout{These paths do not intersect. No bridge, sorry.}%
 \else
  \path[name path=tmp@bridge@path@C] (tmp@i@0) 
    circle[radius=\pgfkeysvalueof{/tikz/bridge radius}]; 
  \tikzset{name intersections={of=tmp@bridge@path@B and tmp@bridge@path@C,
    by={tmp@i@1,tmp@i@2},total=\tmp@i@total}}
  \ifnum\tmp@i@total=2
   \begin{scope}
    \clip (tmp@i@0) circle[radius=\pgfkeysvalueof{/tikz/bridge radius}]
     (current bounding box.south west) |-
     (current bounding box.north east) |- cycle;
    \draw[bridge-style] #1; 
   \end{scope}  
   \path let \p1=($(tmp@i@1)-(tmp@i@2)$),\n1={scalar(int(sign(\x1)))} in
    \ifnum\n1=-1
     pic [draw,line cap=round, angle radius=\pgfkeysvalueof{/tikz/bridge radius},
        bridge-arc] {angle=tmp@i@2--tmp@i@0--tmp@i@1}
    \else 
     pic [draw,line cap=round, angle radius=\pgfkeysvalueof{/tikz/bridge radius},
        bridge-arc] {angle=tmp@i@1--tmp@i@0--tmp@i@2}
    \fi; 
  \else
   \typeout{Given the bridge radius \pgfkeysvalueof{/tikz/bridge radius}, 
    the path is not suited to construct a nice bridge. No bridge, sorry.}%
  \fi   
 \fi 
},bridge radius/.initial=.5ex,
    bridge style/.code={\tikzset{bridge-style/.style={#1}}},
    bridge arc/.code={\tikzset{bridge-arc/.style={#1}}},
    bridge style={},bridge arc={}}
\makeatother
\begin{document}
\begin{tikzpicture}
  \begin{scope}
    \draw[name path=A] (1,0) -- (1,1);
    \tikzset{bridge={(3,.5) to node[above,pos=.33333333333333333333333]{\(\mathit{c3}\colon b\)} (0,.5)} over A}
    \node at (2,.25) {\(\mathit{c3}\colon b\)};
  \end{scope}
\end{tikzpicture}
\end{document}

将其输入pdflatex并以 100% 的放大率打开结果,evince我们会得到一张图像,其中使用桥接指令排版的文本比通常排版的相同文本更粗/更粗:

输出

qpdfview100% 分辨率下,差异类似。在非常高的分辨率下,例如 1000%,我无法观察到 或 的厚度差异evinceqpdfview(边缘锐度可能有微小的、几乎难以辨认的差异。)为什么字体粗细的差异在低分辨率下如此明显,以及如何使使用桥接命令排版的文本粗细与平常相同?

交叉发布:http://latex.org/forum/viewtopic.php?t=34275

答案1

在 PDF 的页面流中,字符串的上部实例在同一位置出现两次,这导致几乎每个 PDF 屏幕查看器都显示为更粗体。这是由于在低分辨率设备上渲染字体字形的贝塞尔曲线时存在不精确性。

为了修复此问题,可以执行以下操作:

路径的第一次出现仅用于计算交点。可以通过将此步骤隐藏在幻影框中来防止将路径插入页面流,幻影框仍会执行计算(但结果必须具有全局范围,因为在\phantom其周围放置了一个组。):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,angles,calc}
%%% Stolen from http://tex.stackexchange.com/a/581548
\makeatletter
\tikzset{bridge/.code args={#1 over #2}{%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 \phantom{%
   \path[name path=tmp@bridge@path@B] #1;
   \tikzset{name intersections={of=#2 and tmp@bridge@path@B,
      by=tmp@i@0,total=\tmp@i@total}}%
   \global\let\tmp@i@total\tmp@i@total%
 }
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 \ifnum\tmp@i@total=0
  \typeout{These paths do not intersect. No bridge, sorry.}%
 \else
  \path[name path=tmp@bridge@path@C] (tmp@i@0) 
    circle[radius=\pgfkeysvalueof{/tikz/bridge radius}]; 
  \tikzset{name intersections={of=tmp@bridge@path@B and tmp@bridge@path@C,
    by={tmp@i@1,tmp@i@2},total=\tmp@i@total}}
  \ifnum\tmp@i@total=2
   \begin{scope}
    \clip (tmp@i@0) circle[radius=\pgfkeysvalueof{/tikz/bridge radius}]
     (current bounding box.south west) |-
     (current bounding box.north east) |- cycle;
    \draw[bridge-style] #1; 
   \end{scope}  
   \path let \p1=($(tmp@i@1)-(tmp@i@2)$),\n1={scalar(int(sign(\x1)))} in
    \ifnum\n1=-1
     pic [draw,line cap=round, angle radius=\pgfkeysvalueof{/tikz/bridge radius},
        bridge-arc] {angle=tmp@i@2--tmp@i@0--tmp@i@1}
    \else 
     pic [draw,line cap=round, angle radius=\pgfkeysvalueof{/tikz/bridge radius},
        bridge-arc] {angle=tmp@i@1--tmp@i@0--tmp@i@2}
    \fi; 
  \else
   \typeout{Given the bridge radius \pgfkeysvalueof{/tikz/bridge radius}, 
    the path is not suited to construct a nice bridge. No bridge, sorry.}%
  \fi   
 \fi 
},bridge radius/.initial=.5ex,
    bridge style/.code={\tikzset{bridge-style/.style={#1}}},
    bridge arc/.code={\tikzset{bridge-arc/.style={#1}}},
    bridge style={},bridge arc={}}
\makeatother
\begin{document}
\begin{tikzpicture}
  \begin{scope}
    \draw[name path=A] (1,0) -- (1,1);
    \tikzset{bridge={(3,.5) to node[above,pos=.33333333333333333333333]{\(\mathit{c3}\colon b\)} (0,.5)} over A}
    \node at (2,.25) {\(\mathit{c3}\colon b\)};
  \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容