[Tex/LaTex] Pigpen-like symbol for =

fontssymbols

I would like to use symbols which look like the pigpen cypher symbols

enter image description here

One symbol I need consists of the two horizontal edges of the square, and the other has the vertical edges in it. I cannot just use = (and its rotation) because the lines are too close to each other. I've looked in the Comprehensive LaTeX Symbol List but could not find any symbol like that. Where could I get hold of such a symbol?

Best Answer

Here, I introduce \pigpenXXXX where XXXX is some combination of 0 and 1 that signify strokes on the left, top, right, bottom (i.e., clockwise starting on left). Stroke length and width are defined by \rlln and \rlwd, respectively. The symbols are defined to sit on the baseline.

Naturally, one could define letters like \def\ppA{\pigpen0011}, etc.

EDITED to make suitable for use in math mode, though it will also function in text mode.

\documentclass{article}
\usepackage{stackengine}
\newlength\rlln
\newlength\rlwd
\newlength\brlwd
\newlength\trlwd
\newlength\lrlwd
\newlength\rrlwd

\rlwd=.5pt
\rlln=5pt
\def\bstr{\rule{\rlln}{\brlwd}\rule{0pt}{\rlwd}}
\def\tstr{\rule{\rlln}{\trlwd}\rule{0pt}{\rlwd}}
\def\lstr{\ooalign{\rule{\lrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\rstr{\ooalign{\rule{\rrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\gap{\rule{\dimexpr\rlln-2\rlwd}{0pt}}
\def\pigpen#1#2#3#4{\kern1pt% FOUR ARGUMENTS ARE LEFT, TOP, RIGHT, BOTTOM STROKES
  \brlwd=#4\rlwd\relax%
  \trlwd=#2\rlwd\relax%
  \lrlwd=#1\rlwd\relax%
  \rrlwd=#3\rlwd\relax%
  \stackengine{\dimexpr\rlln-\rlwd}{%
    \stackengine{0pt}{\bstr}{\lstr\gap\rstr}{O}{c}{F}{F}{L}%
  }{\tstr}{O}{c}{F}{F}{L}\kern1pt%
}
\begin{document}
$x\pigpen0011 \pigpen1011 \pigpen1001 \pigpen0111
\pigpen1111 \pigpen1101 \pigpen0110 \pigpen1110
\pigpen1100 \pigpen1010 \pigpen0101 y$
\end{document}

enter image description here

UPDATE:

The OP requested a version with rounded endcaps. To do so, I use my custom style file roundrule.sty, found exclusively at the end of this answer:

Is there such a thing as a `\mathrule`? (rounded endcaps)

I then modify my above answer to use round rules instead of rules. I probably need to update roundrule.sty, because I found that if one of the rule dimensions is 0pt, it still outputs a thin line. To circumvent that problem for this answer, I perform a check on the roundrule dimensions.

\documentclass{article}
\usepackage{stackengine,roundrule}
\newlength\rlln
\newlength\rlwd
\newlength\brlwd
\newlength\trlwd
\newlength\lrlwd
\newlength\rrlwd
\newcommand\rrule[2]{\ifdim#1>0pt\relax\ifdim#2>0pt\relax\roundrule{#1}{#2}\else\fi\else\fi}

\rlwd=.5pt
\rlln=5pt
\def\bstr{\rrule{\rlln}{\brlwd}\rule{0pt}{\rlwd}}
\def\tstr{\rrule{\rlln}{\trlwd}\rule{0pt}{\rlwd}}
\def\lstr{\ooalign{\rrule{\lrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\rstr{\ooalign{\rrule{\rrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\gap{\rule{\dimexpr\rlln-2\rlwd}{0pt}}
\def\pigpen#1#2#3#4{\kern1pt% FOUR ARGUMENTS ARE LEFT, TOP, RIGHT, BOTTOM STROKES
  \brlwd=#4\rlwd\relax%
  \trlwd=#2\rlwd\relax%
  \lrlwd=#1\rlwd\relax%
  \rrlwd=#3\rlwd\relax%
  \stackengine{\dimexpr\rlln-\rlwd}{%
    \stackengine{0pt}{\bstr}{\lstr\gap\rstr}{O}{c}{F}{F}{L}%
  }{\tstr}{O}{c}{F}{F}{L}\kern1pt%
}
\begin{document}
$x\pigpen0011 \pigpen1011 \pigpen1001 \pigpen0111
\pigpen1111 \pigpen1101 \pigpen0110 \pigpen1110
\pigpen1100 \pigpen1010 \pigpen0101 y$
\end{document}

enter image description here