2

I have seen some people do some mind boggling things on this site using powerful packages (and standalone code) based on pgf and tikz. This question (How to get intersection point(s) of two glyphs?) got me thinking about some of the simple rules and relationships that might be necessary between text and extra ornaments.

I recently saw a title block (likely created by a graphic artist) that created a neat effect only in part by the selected font (which I have no idea what it is)

I have uploaded a sample from this title, and will try and describe the effect that I liked.

  • A line surrounds/straddles the small caps letters, but doesn't intersect the Full caps or hanging letters
  • in the example, I infer the behavior of a hanging letter from the R, which I guess to be a small caps letter with a flourish or ornament.

enter image description here

I am relatively new to tikz, and I am reading the manual, but the copy I am working with is over a thousand pages long and since I have a limited tikz vocabulary I may not be looking for the right topics to get me on the right track.

I am posting tonight in the hopes that I can get some feedback on my two approaches detailed below, and get some direction to create a dynamic solution to this (if possible).

Question 1 Can I outline text with another color (black text with a white outline), or will tikz only see and outline the rectangular bounding box? My logic here is that if I draw the lines in, and superimpose a transparent text box. I will see both my text and my lines. If I then can trace an outline of the text (with white), it will have the effect of washing out part of the lines without having to worry about where to start and stop the line.

Question 2 I thought maybe letters in individual node/textboxes might be consistently positionable with common relationships I could program into a function/loop. Do letters created in tikz come with any of there own implicit nodes? I was thinking if I could use the nodes of a letter like the nodes of a textbox. I don't know what merit this idea had, because when the effect was made a bit more obvious by using the bounding boxes, it was clear that the code would have no idea what side of the letter the ornament would be on.

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
        \node (L1) at (0,0) {T};
        \node (L2) at (1,0) {\scshape {r}};

        \draw (L1.north east) -- (L2.north west);
        \draw (L1.south east) -- (L2.south west);
    \end{tikzpicture}
\end{document}

I like being able to do things like this dynamically, but I have to say, I don't even know if this is possible, or if the inconsistent overlap in placements I would have to create to align the letters would make this impossible and better left as a graphic import after being designed in alternate software.

Note: I was able to get a lot closer when I manually created nodes based on distances but if I have to do that, I might as well just assemble in GIMP or something.

6

Package pdfrender (for pdfTeX/LuaTeX in PDF mode) can draw vector fonts with rendering mode "stroke", where the color and line width of the outlines can be configured. The following example uses \overline and \underline for the lines without the need for TikZ.

\documentclass{article}
\usepackage{lmodern}
\usepackage{pdfrender}
\usepackage{xcolor}

\newcommand{\OverUnderLine}[1]{%
  \leavevmode
  \begingroup
    \setbox0=\hbox{#1}% contains the text
    \setbox2=\hbox{m}% height for the overline
    % Set invisible rule with original height and depth
    \vrule width 0pt height\ht0 depth\dp0\relax
    \rlap{%
      $\underline{\overline{%
        % phantom text box without text and reduced height without depth
        \vrule width0pt height\ht2\kern\wd0 %
      }}$%
    }%
    % Stroke text with white color
    \rlap{%
      \textpdfrender{%
        TextRenderingMode=Stroke,
        LineWidth=1pt,
        StrokeColor=white,
      }{\copy0}%
    }%
    % Original text
    \copy0\relax
  \endgroup
}

\begin{document}
  \OverUnderLine{Quisque ullamcorper placerat ipsum.}
\end{document}

Result

  • Thanks. I'm blown away! I may have to switch over to luatex to be able to use this, and for surprising reasons right now, I can't compile a luatex document on my windows machine, I will check asap on my linux machine. Thanks for explicitly pointing out that this wouldn't work in XeLaTeX, it compiled fine first go round, but if I hadn't taken a closer look, I wouldn't have noticed that the line wasn't in fact interrupted. – EngBIRD May 27 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.