I think you should use a fixed width font (e.g. Courier New) and height units.
In fact, this was a nice little demo to work on. Is this what you’re looking for?
Letter Detection code | try it
Click on the letter e. Lines are split using \n in a code component. This is not sophisticated enough to split wrapped lines.