7

This is one of my favorite problems. Enjoy!

We'd like to make holes in the text to make it look more tasty, like cheese tasty. We can find several fonts for this purpose, but we cannot (pseudo-randomly) change the location of the holes. That's pity! Could it be done in TeX to get something like this (the change of the background color should be a proof that there are holes not only circles drawn with the same color as the initial background color)? I enclose a close-up and some variants.

mwe, close-up

mwe

Update

We cannot use the background color, if there is any, for circles: we would face a problem of shaded and other type of backgrounds. I enclose an example.

mwe with different background

Minimal working example

If we need some minimal working example (let's call it a static solution), this is it using two fonts available from Dafont.com, Cheese and Mouse font and JI Swiss Cheese font. After downloading the ZIP files, unzipping them, deleting spaces in filenames and installing them we can use them (xelatex and lualatex engines can be used):

\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{fontspec}
\begin{document}
\setmainfont{JISwissCheese.ttf}
JI Swiss Cheese\par
\setmainfont{CheeseandMouse.ttf}
Cheese and Mouse
\end{document}

mwe via two fonts

A tip if you got stuck

Back in 2011, I've found this Q+A, it helped me a lot to solve this particular task for TeX hobbyists, How can I invert a 'clip' selection within TikZ? As long as I remember it was one of the first TeX.SX websites I visited.

9
  • 5
    You definitely have too much time :-) Looks funny and good! – user31729 May 26 '14 at 7:16
  • 1
  • 1
    Additionally, I hope, nobody changes the title of the 'question' to How to make my text more nasty ... – user31729 May 26 '14 at 14:24
  • Is it a real question then? – ienissei May 26 '14 at 14:33
  • 1
    @ienissei Of course, it's done! – Malipivo May 26 '14 at 22:00
7

I've tried to submit a gift/surprise question to my fellow solvers and I've originally marked it as solved because I know that feeling trying to solve some difficult question when I suddently discover that it has already been solved. But I didn't want to spoil the fun by submitting an anwer right away.

I enclose my original solution from 2011 with some updates. I've never used it in real typography, it was just an example for the audience (non-TeXists) of what TeX could handle. This Q+A at TeX.SX helped me a lot back then, How can I invert a 'clip' selection within TikZ?

% run: any latex engine; mal-cheese.tex
\def\maltext{My tasty example}

\documentclass{article}
\usepackage{fontspec}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\pagestyle{empty}
\parindent=0pt

\begin{document}
%\setmainfont{[csb10]} % My original font for xelatex...
\bfseries
\fontsize{40}{72}
\def\empty{}

% This has been my original setting which requires two runs of TeX...
\ifx\relax
\tikzstyle{reverseclip}=[insert path={
  (current page.north east) --
  (current page.south east) --
  (current page.south west) --
  (current page.north west) --
  (current page.north east)}]
\fi
% This is a new approach which requires only one run of TeX...
\tikzset{reverseclip/.style={clip, insert path={{[reset cm] (-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)
    }}}}

\def\typesetme#1{%
\newpage
\if#1\empty\else%\pagecolor{#1} % My original setting...
\fi
%\def\vlastniobjekt{% a new command
\setbox0=\hbox{%
\begin{tikzpicture}%[remember picture, overlay,
  [m/.style={clip,rounded corners}, outer sep=0pt]
\begin{pgfinterruptboundingbox} 
\shade[left color=#1, right color=yellow] (-70mm,-2cm) rectangle (7cm,4cm);
\node[yshift=10mm, %fill=#1, % right color=yellow, 
minimum height=4cm] at (0mm,0) {\raisebox{6mm}[0pt][0pt]{\maltext}}; % \muj
\pgfmathsetseed{101}%100
\foreach \a in {1,...,600}{
\pgfmathrandominteger{\x}{-62}{62}
\pgfmathrandominteger{\y}{-6}{7}
\path (\x mm,\y mm) circle (0.9mm) [reverseclip];
%\draw (\x mm,\y mm) circle (.8mm);
}
\end{pgfinterruptboundingbox}
\node at (0mm,0) {\maltext}; %\muj
\end{tikzpicture}}% konec \hbox...
%}% end of new command
%\vlastniobjekt % activating a new command...
\copy0%
}% End of \typesetme...

\ifx\relax
% This has been my original example to the audience...
%\typesetme{} % white
\foreach \barva in {0,10,...,100} {
  \typesetme{yellow!\barva}
  } % intensity of yellow
\foreach \barva in {100,90,...,0} {
  \typesetme{green!\barva}
  } % intensity of green
\fi

% An example for TeX.SX...
\typesetme{red}
\typesetme{blue}
\typesetme{green}
\end{document}

mwe

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.