How can I take input text and replace each character with a solid (and/or hollow) rectangle representing the bounding box for that character? In the case where two characters are closer together from kerning (e.g. microtype
) the boxes would overlap. The addition of the boxes should not change the spacing of the text – I'm looking for a "draft mode" for the letters.
Solutions and Problems
Both solutions presented by Yiannis Lazarides and egreg seem to do a reasonable job for single words, though as mentioned, it seems that kerning was not completely respected. Below are the results (without markup/egreg/Yiannis):
Both solutions fail however when multiple words are involved. One of the answers completely eats a space while the other overcompensates. Both of them seem to choke on a line break as well.
Best Answer
A LuaTeX solution. Should work in all situations that I am aware of:
which yields:
(detail)
Bonus: it draws the base line if the depth of the glyph is not 0.
Here is a solution that replaces the glyphs by black rectangles (rules):