I'm trying to draw text in shapes (using scaling and path). I want text to show up like this:
I've tried a lot of different methods, but I'm having trouble doing so. I can get close to it using something like this:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\pagenumbering{gobble}
\begin{tikzpicture}
\node (One) at (-15,0) {.};
\node (Two) at (15,0) {.};
\draw [decorate,decoration={text effects along path,
text={TTTTTTTTTTTTTTTT},
text align=center,
text effects/.cd,
path from text,
character count=\i, character total=\n,
characters= {text along path, scale=(2 + abs(\i - (\n / 2) - 0.5) * 1 )}}] (One) to (Two);
\end{tikzpicture}
\end{document}
Which results in :
I want the top of the text to curve up like the example shown.
Best Answer
I just threw in the
\outline
macro (requires pdflatex) for the fun of it.The
\outline
stuff is in the preamble, whereas the necking code is in the main document. I originally stole the code that makes up\outline
from Malipivo at TikZ: halo around text?What I do is create a box (
\mytext
) with the text (padded a little so that none gets subsequently clipped), and then successively apply a\clipbox
that vertically slices the text box\cuts
times. On each cut, I apply a\scalebox
to shrink the text as a function of the cut number and\dip
, which represents the maximum necking fraction. The function I choose here is parabolic, though others can be developed as well.Without the
\outline
code, the code is more manageable. (EDITED) Here I convert it into a macro\parabtext[<mode>]{<lift>}{<neck>}{<cuts>}{<content>}
with several additions from above:<mode>
is 0 for narrow middle, and 1 for narrow ends;<lift>
is the fractional max-lift of the baseline during the transformation<neck>
is the fractional reduction in total height at the neck;<cuts>
are the number of vertical slices to apply to the box (too small, and it will look stair-stepped)<content>
is the stuff to put in a box and transform.The most recently EDITED option,
<mode>
, changes the shape function of the transformation. In both modes, a function is evaluatedThat is a parabola that is at a value of 1 at both ends of the box and a value of 0 at the middle of the box. Then, if the mode is 0, the transformation is
whereas, if not zero, the transformation is
This simple difference will produce the necked and barrelled versions, respectively.
PROPOSED METHODOLOGY
The method is somewhat computationally expensive, but it is intended to be used sparingly for the Wow! effect.
First, I'll show a slightly modified code that takes it, in effect, from a forward difference to a central difference, though it may cost a little more in computation.
But what I think works best is to set the number of slices in a user defined variable to a low number, say
\def\slices{5}
and develop your document on that basis. On the final compilation, when all is set in the final layout, then re\def\slices
to the desired number, say{200}
, and recompile one last time.Here is, for example, the output with
\slices
set to5
for the lo-res compilation:NOTE TO XeLaTeX USERS
The OP noted that this approach failed to work in XeLaTeX. After some study, I boiled the problem down to a bug in the
trimclip
package (\clipbox of a \scalebox not working properly in xelatex). Joseph Wright was kind enough to diagnose the issue and provide a patch for thetrimclip
code, when running in XeLaTeX.