6

I'd like to achieve such a result, like when you apply a glowing effect to a text in an image editor. enter image description here


As I am already using tikz package in my document, it would be prefferable to use tikz's library.

I found out, that there is a shadows.blur one which would create a soft shadow. Then I would shift it so that it looks like a glowing effect.

However, unfortunately, this attempt makes a rectangle rather than the text's shadow.

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\begin{document}

\begin{tikzpicture}
\node[preaction={blur shadow={shadow xshift=-.5mm,shadow yshift=.5mm}}] at (1,1) {Test};
\end{tikzpicture}

\end{document}

enter image description here

11

You could use a combination of tikz and contour package.

\documentclass[12pt,border=12pt]{standalone}
\usepackage[outline]{contour}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\def\mycontour#1{\textcolor{black}{\contour{green!20}{#1}}}
\node (1) at (0cm, 0cm) {};
\node (2) at (2cm,0cm) {};   
\draw[
decoration={text effects along path,
text={Text},
text align=center,
text effects/.cd,
text along path, scale text to path,
characters={font=\Huge,character command=\mycontour},
},decorate,
]  (1) to (2);
\end{tikzpicture}
\end{document}

or just

\documentclass{article}
\usepackage{xcolor}
\usepackage[outline]{contour}
\contourlength{1pt}
\contournumber{27}
\newcommand{\mycontour}[2][green!20]{\textcolor{black}{\contour{#1}{#2}}}
\begin{document}
\Huge\mycontour{Text}
\end{document}

enter image description here

| improve this answer | |
  • @Schrödinger's cat, yes. I have edited the answer. – rakatex May 23 at 21:26
  • @Schrödinger's cat, sometimes its not working without decorations.text. Could you tell me why? – rakatex May 23 at 21:32
  • @Schrödinger'scat yes, your code is more simpler and straightforward. \documentclass[12pt,border=12pt]{standalone} \usepackage{xcolor} \usepackage[outline]{contour} \newcommand{\mycontour}[2][green!20]{\textcolor{black}{\contour{#1}{#2}}} \begin{document} \Huge\mycontour{Text} \end{document} – rakatex May 23 at 21:43
  • 2
    Just add it as an alternative to your answer, if you like. – user194703 May 23 at 21:44
  • 1
    I just added it. Then you do not need to reintroduce the line breaks. – user194703 May 23 at 21:48
8

Just one step further from the previous answer. This one uses the idea of Faded or blurred lines

\documentclass{article}
\usepackage{tikz}
\usepackage[outline]{contour}

\begin{document}

\Huge

Assume pdf\TeX

\def\exText{LIPSUM}

\makeatletter

    Reverse engineer the contour package.

    Here is an MWE
    \leavevmode
    \begingroup
        \color{green}%
        \con@coloroff
        \pdfliteral{%
            q % enter a scope
            1 j % Set line join style
            1 J % Set line cap style
            1 Tr % Set text rendering mode
            2.5 w % Set line width (in PostScript Point)
        }%
        \rlap{\exText}%
        \pdfliteral{%
            Q % leave the scope
        }%
    \endgroup
    \mbox{\exText}


    Now use TikZ.
    \leavevmode
    \pgfsys@beginscope% = pdf literal q
    \pgfsetroundjoin% = 1 J
    \pgfsetroundcap% = 1 j
    \pdfliteral{1 Tr}% no pgf alternative
    \foreach\ind in{10,...,1}{%
        \pgfmathsetmacro\per{(11-\ind)*5}%
        \color{green!\per}%
        \pgfsetlinewidth{\ind/2}%
        \rlap{\exText}%
    }%
    \pgfsys@endscope % = pdf literal Q
    \exText

\makeatother

\end{document}

| improve this answer | |
  • Maybe, maybe not. I think that one can use the trick of superimposing relatively shifted characters for the contour, but there will be limits. I played some time ago with copy shadow and the problem was that it depends on the path whether it looks good. But yes, for these characters the results are good. – user194703 May 24 at 6:49
  • @Schrödinger'scat Also try this ``` Right arrows? \def\exText{$\rightarrow\Rightarrow$} \pdfliteral{q 1 j 1 J 1 Tr}\foreach\per in{5,10,...,50}{\color{green!\per}\pgfsetlinewidth{(50-\per)/10}\rlap{\exText}}\pdfliteral{Q}\exText ``` – Symbol 1 May 24 at 6:52
  • I am always wondering why it is that asymptote and pstricks can access the path of glyphs but TikZ has such a hard time. I know your nice solutions of "decomposing the world in triangles" but I am always hoping that one day TikZ will know what the path for a glyph for an A, say, of a given point is. And as for your last point, can't one use copy shadow to do that for an arbitrary content? But yes, it looks good! – user194703 May 24 at 6:53
  • I have no idea why pstricks has access to so much things, this and z-sorting of 3D objects. Asymptote can do more because it's standalone. But pstricks...? I don't understand. – Symbol 1 May 24 at 6:55
  • copy shadow is O(m). Glowing by varying line width is O(n). Combining copy shadow and varying line width is O(mn). The hight complexity keeps m and n small, which is bad. The triangulation trick is the worst because it alone is O(mn). I only do them for the mere possibility. – Symbol 1 May 24 at 7:03

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.