In this example, the bit representation of BIOS font from '@' to 'G' is in two forms. The first is a sequence of 1s and 0s separated by commas. The second is a string of 1s and 0s crammed into tokens. Truth be told, I want to have a single macro which generates a tikzpicture from the second form. This is as far as I got, and I need help to finish it.
Running 'pdflatex BIOS.tex' with this as its source does the right thing with the first form and fails to output the second form. The code is actually broken, but the goal is to have indices (\xi,\yi) and a \chr to place a filled circle for each \chr in each \row.
Please help me finish this. I don't know what to try and no search result worked.
\documentclass[12pt]{article}
\usepackage{tikz}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO make this work by enumerating each character with \xi
\makeatletter
\def\dowithchar#1#2{%
\begingroup%
\def\myspace{}% defined with local scope
\@tfor\chr:=#1\do{%
\myspace\ifx\chr{X} \fill (0.18*\xi,-0.18*#2) circle (0.08) \fi;%
\let\myspace\space%
}%
\endgroup%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatother
\listfiles
\begin{document}
\newcommand\ASCIIbits{
{0,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,%
0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0},%
{1,1,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,%
0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0,1,1},%
{1,1,0,1,1,1,1,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,%
0,0,1,1,0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,0,1,1,0,1,0,0,0,0,1,1,0,0,0,0,0},%
{1,1,0,1,1,1,1,0,0,1,1,0,0,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OOXXOOXXOOXXOOOOOOOOXXOOXXOOOXXOXOOOOOXXOXOOOOXXOOXXX,%
XXOOOOOOOXXOOXXOOOOXXOOXXOOOXXOOXXOOOXXOXXOOOOXXOOOXOOOXXOOOOOOOXXOOXX,%
OXXXXXOOOXXOOXXOOOXXXXXXOOOOOXXXXOOOXXXXXOOOOXXXXXXXOOXXXXOOOOOOOXXXOX,%
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO%
}
\begin{tikzpicture}
\foreach\row [count=\yi] in \ASCIIbits{
\foreach\chr [count=\xi] in \row {
\ifodd\chr \fill (0.18*\xi,-0.18*\yi) circle (0.08) \fi;
}
}
\end{tikzpicture}
\begin{tikzpicture}
\foreach\row [count=\yi] in \ASCIIfont{
\dowithchar\row\yi
}
\end{tikzpicture}
\end{document}



A follow-on question is "why does latex make this so hard?" I could do this quickly, simply, and easily in any of a dozen different programming languages.
Perhaps I shall write a preprocessor to generate latex so that these kinds of operations are more easily done. Perhaps a Python library which can be used by authors to write source generators. Kind of like a mediawiki syntax reader that outputs latex.
Nevertheless... THANK YOU!
– jlettvin Feb 25 '20 at 15:06circle (0.08)is deprecated by now.) – Feb 25 '20 at 15:12m4), doing “moderately complex things” appears very difficult when you are not well versed in the system. One really needs a lot of practice to... – frougon Feb 25 '20 at 16:01etoolbox,sparse, etc.), yet they are arguably not documented as well as they could. The package documentations are largely great, but there is, to my knowledge, no resource written by an objective that I am aware of that tells one in simple terms "if you have this problem you need to load that package and use this-and-that macro". – Feb 25 '20 at 16:17