Here's a solution that can be used with \fboxs (though the /utils/TeX/ifx key can only properly be loaded with TikZ/\usetikzlibrary) or TikZ.
The core of it is to iterate through a bunch of characters and do the same to them. What is done with them is the task of /boxes/place letter.
This could be a simply \fbox:
\boxesset{place letter/.code=\fbox{#1}}
but it can also be a \node inside a TikZpicture.
The value-keys at start and at end can be used to wrap the whole placing inside something.
I've defined two styles:
fbox:
This places each letter in a \fbox. The at start key is used to set the font size and lengths for the \fbox.
tikz:
This places each letter as a node that's part of chain going to the right. The at start and at end values are used to place the whole thing inside a tikzpicture with the appropriate settings.
This allows you to simply do
\boxes[fbox]{Text}
% or
\boxes[tikz]{Text}
Or you define your own macro that uses one of those so that you don't have to specify it everytime.
Since the algorithm that looks at the given letters isn't very smart it needs special consideration with characters that are accented or umlauts. Just put those in braces {ä}. With LuaLaTeX, this isn't needed anymore (but it doesn't hurt either.
Things like \textit{r} will always need braces: {\textit{r}}.
Otherwise, the algorithms assumes \textit to be its own character and that will fail because it misses its argument.
Literal spaces will be ignored. The \fbox approach just needs ~ or \␣, the TikZ solution needs {~~} or {\␣\␣}.
The TikZ solution uses baseline so that the baseline of the letters are at the actual baseline of the text and trim left, trim right and outer sep=0pt so that no line width contributed to the bounding box (excluding the top and the bottom lines).
The definition of /utils/TeX/ifx without ext.misc is:
\makeatletter
\pgfkeys{
/utils/TeX/ifx/.code n args={4}{%
\ifx#1#2\relax\expandafter\pgfutil@firstoftwo\else\expandafter\pgfutil@secondoftwo\fi
{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}}}
\makeatother
Code
\documentclass{scrartcl}
\usepackage{tikz}\usetikzlibrary{chains,ext.misc}
\pagestyle{empty}
\newcommand*\boxesStop{boxesStop}
\newcommand*\boxesset{\pgfqkeys{/boxes}}
\boxesset{
.code=\boxesset{#1},
at start/.initial=,
at end/.initial=,
place letter/.code={#1},
place letters/.style={@place letters={#1\boxesStop}},
@place letters/.style 2 args={place letter={#1},
/utils/TeX/ifx={\boxesStop}{#2}{}{@place letters={#2}}}}
\newcommand*{\boxes}[2][]{%
\begingroup
\boxesset{#1}%
\pgfkeysvalueof{/boxes/at start}%
\boxesset{place letters={#2}}%
\pgfkeysvalueof{/boxes/at end}%
\endgroup}
\boxesset{
fbox/.style={
at start=%
\fontsize{100pt}{0pt}\selectfont
\setlength{\fboxsep}{-.1pt}%
\setlength{\fboxrule}{.1pt},
place letter/.code=\fbox{##1}},
tikz/.style={
at start={%
\begin{tikzpicture}[baseline=(chain-begin.base),
trim left=(chain-begin.west), trim right=(chain-end.east),
node distance=+0cm, start chain=going base right,
nodes={draw, line width=+.1pt, inner sep=+0pt, outer sep=+0pt,
font=\fontsize{100pt}{0pt}\selectfont}]},
at end=\end{tikzpicture},
place letter/.code=\node[on chain]{##1};},
}
\newcommand*{\dblSpc}{\ \ }
\begin{document}
\begin{tabular}{rll}
& \texttt{fbox} & \texttt{tikz} \\
plain & \boxes[fbox]{Abstract} & \boxes[tikz]{Abstract} \\
special & \boxes[fbox]{Abstr{ä}ct{\textit{r}}} & \boxes[tikz]{Abstr{ä}ct{\textit{r}}} \\
overlapping & \multicolumn{2}{c}{\rlap{\boxes[fbox]{Abstract}}\boxes[tikz]{Abstract}} \\
spaces & \boxes[fbox]{S p a c e s} & \boxes[tikz]{S p a c e s} \\
& \boxes[fbox]{S\ p~a\ c~e\ s} & \boxes[tikz]{S{\ \ }p{~~}a\dblSpc c{~~}e{\ \ }s}
\end{tabular}
\end{document}
Output

anchor=base, hence your nodes are anchored to their bases. What would you expect? When I run tour code (which got a typo on the first line), I got a perfectly aligned set of boxes.Please be more specific about what you want, because I can see no error here. – SebGlav Oct 05 '22 at 11:23lua-visual-debugpackage. – Qrrbrbirlbel Oct 06 '22 at 09:00