59

On a related note to How do I make my document look like it was written by a Cthulhu-worshipping madman?, I want to create a LaTeX command that blurs the text so it's unreadable.

Unfortunately, whatever I google to get ideas on how to do this, I find forum posts from everyone and his aunt having problems with the fonts being blurry. Nothing about how to get there...

Tomas Aschan
  • 15,528

4 Answers4

51

Using a variation of the technique Dissecting paragraphs with \lastbox described in Section 5.9.6 of TeX by Topic, you can produce a blur effect; the idea is to use two copies for each line and typeset the line and its copies superimposed:

\documentclass{article}
\usepackage{lipsum}

\newbox\flinebox 
\newbox\slinebox
\newbox\mlinebox
\def\duplines{\setlength\parindent{0pt}
  \setbox\flinebox\lastbox
  \ifvoid\flinebox\relax
  \else
  \setbox\slinebox\hbox{\copy\flinebox}
  \setbox\mlinebox\hbox{\copy\flinebox}
  \unskip\unpenalty
  {\duplines}
  \box\flinebox\vspace*{-2.3ex}
  \box\mlinebox\vspace*{-2.3ex}
  \box\slinebox \fi
}

\newcommand\BlurText[1]{%
  \vbox{#1\par\duplines}}

\begin{document}

\BlurText{\lipsum[1]}

\end{document}

enter image description here

In a comment, doncherry suggested horizontally shifting the layers to decrease legibility; this can be done using this definition of \duplines:

\def\duplines{\setlength\parindent{0pt}
  \setbox\flinebox\lastbox
  \ifvoid\flinebox\relax
  \else
  \setbox\slinebox\hbox{\copy\flinebox}
  \setbox\mlinebox\hbox{\copy\flinebox}
  \unskip\unpenalty
  {\duplines}
  \box\flinebox\vspace*{-2.4ex}
  \makebox[\textwidth]{\hspace*{2pt}\box\mlinebox}\vspace*{-2.4ex}
  \makebox[\textwidth]{\hspace*{4pt}\box\slinebox}\fi
}

and defining \BlurText as before, here's the new result of \BlurText{\lipsum[1]}:

enter image description here

And a little modification using some color:

\usepackage{xcolor}

and in \duplines:

  {\color{black!50}\box\flinebox\vspace*{-2.4ex}
  \makebox[\textwidth]{\hspace*{2pt}\box\mlinebox}\vspace*{-2.4ex}
  \makebox[\textwidth]{\hspace*{4pt}\box\slinebox}}

enter image description here

Nikos Alexandris
  • 1,051
  • 1
  • 15
  • 43
Gonzalo Medina
  • 505,128
6

Here is a TikZ-solution.

\newcommand{\blurred}[3]{
\draw [black!#1] node at (#2,#2) {#3};
\draw [black!#1] node at (0,#2) {#3};
\draw [black!#1] node at (#2,0) {#3};
\draw [black!#1] node at (-#2,#2) {#3};
\draw [black!#1] node at (-#2,0) {#3};
\draw [black!#1] node at (0,-#2) {#3};
\draw [black!#1] node at (#2,-#2) {#3};
\draw [black!#1] node at (-#2,-#2) {#3};
}

\newcommand{\blurry}[1]{
\blurred{5}{0.04}{#1}
\blurred{13}{0.017}{#1}
\blurred{10}{0.012}{#1}
\blurred{15}{0.007}{#1}
\blurred{20}{0.003}{#1}
\blurred{10}{0.0015}{#1}
\draw [black!40] node at (0,0) {#1};
}

For example:

\begin{tikzpicture}
\blurry{This text is a little bit blurry.}
\end{tikzpicture}

blurry example

In order to strengthen the blur effect, you will have to play with the numbers in the \blurry-command.

3

Another tikz solution, using a loop to draw the blur

\newcommand{\blurry}[2]{
% Draw the blur
\foreach \a in {0,5,...,360}
{   \foreach \r in {0,.1,...,1}
    {   \draw [black, opacity=0.02] node at (\a:\r ex) {#1};
    }
}

% Draw the solid text \draw [#2, opacity=1.0] node at (0,0) {#1}; }

\begin{tikzpicture}
\blurry{This text is a little bit blurry.}{white}
\end{tikzpicture}
  • Slightly change the code (https://i.imgur.com/aAwvhjI.png), I got nice results like here : https://i.imgur.com/WxhfqWL.png. – Watson Jan 05 '21 at 18:41
1

Another way similar to Dylans; But for producing such a glowing script in any color, inline or even multiparagraph long with automatic linebreak, though sometimes \par is accepted and sometimes you seem to need \\ to prevent errors. enter image description here

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{external}\tikzexternalize%Important to keep compiling time down, since 1 single line has a few hundred overlays of different pictures (AngleSpacing* Radii spacing) 
\usepackage{pagecolor}%since a black background looks nice for this script
\usepackage[x11names]{xcolor}

%Defining Colors to be used

\definecolor{Vlad}{RGB}{254,154,132} \definecolor{Vlad2}{rgb}{0.6,0,0} \definecolor{Vlad3}{RGB}{77, 14, 10} \definecolor{Giggler}{RGB}{240,165,85} \definecolor{Anax2}{RGB}{46,139,87} \definecolor{Anax1}{RGB}{154,205,50} \definecolor{BoS1}{RGB}{222,184,135} \definecolor{BoS2}{RGB}{165,42,42} \definecolor{Dion1}{RGB}{228,191,250} \definecolor{Dion2}{RGB}{148,0,211}

\pagecolor{black}\color{white} \begin{document}

\newcommand{\ghostfontnow}[3]{%3 Vairables for the Font; #1Color of the Core of your font; #2Color of the Blur around your font #3 the Text you want to blur \pgfmathsetmacro{\blurshradius}{1.5}%Like the Name says the Radius of the bluring for the shadowlike effect in units of ex so in heights of the letter x % further variables used in dependence on the chosen blur Radius \pgfmathsetmacro{\linesxoffsetsh}{2\blurshradius} \pgfmathsetmacro{\lineyoffsetsh}{1.4\blurshradius} \pgfmathsetmacro{\blurshradiusspacing}{\blurshradius*0.1} \hspace{-\linesxoffsetsh ex}\raisebox{-\lineyoffsetsh ex}{\begin{tikzpicture}% since the blurs define the corners of the tikz box you have to readjust its position to be placed correctly inline \draw [#1, opacity=1,align=left,text width=\textwidth] node at (0,0) {\rmfamily\bfseries\itshape#3\mdseries\upshape\sffamily};% Draw the solid text in the center \foreach \a in {0,10,...,360}{%go the full 360 degree in a circle by 10 degree steps \foreach \r in {0.,\blurshradiusspacing,...,\blurshradius}{%do it for different Radii from smallest chosen Radius to full Radius \draw [#2, opacity=0.02,align=left,text width=\textwidth] node at (\a:\r ex) {\rmfamily\bfseries\itshape#3\mdseries\upshape\sffamily};% Draw the blur, by overlaying lowly transparent Text for all Radii and Angles %Also Changing from serif less Normal script to serif, bold, italic for the text and back } }

\end{tikzpicture}}} \par Before the Picture some text:\par \newcommand{\ghostfonttest}[2]{First seeing how it aligns inline\ghostfontnow{#1}{#2}{#1 is Color 1}\par \ghostfontnow{#1}{#2}{#2 is color2}\par \ghostfontnow{#1}{#2}{Now how it aligns by itself.\par BlurrR Version:This text is a little bit blurry. Testing if the text produces correct formatting, if text is placed before the relevant parts. Testing if it is bugged in this case also relevant to know whether the command auto line breaks or whether it would have to always be done manually}} \ghostfonttest{Vlad}{Vlad2}\par \ghostfonttest{Anax1}{Anax2}\par %\ghostfonttest{BoS1}{BoS2}\par \ghostfonttest{Dion1}{Dion2}\par \end{document}

Till
  • 13