Tuesday, June 02, 2015

Fun With Fonts – Adding A Little Extra Information

This week I was working through some examples of looping with students in my Explorations in Computer Science course.  We created a simple program with some nested loops to print some old-fashioned ASCII art. We created a triangle like the one below.

imageSimple enough. While I was working through the exercise before class it occurred to me that, logically, the result shouldn’t come out this way. I was, to my way of thinking, putting too many spaces in each row. Then it occurred to me that the font was responsible. The font in the listbox was the default font – Microsoft Sans Serif, which is a proportional font. That means that different characters take up different widths. Blank spaces are not as wide as the letter “X” and that accounted for the spacing.


The obvious next step was to change the font to a monospaced font such as Courier New which I did. The resulting image lines up quite differently even though the code is exactly the same.

Since this course is about a lot more than just programming, which takes up about a third of the semester, this provided something new to talk about.

Few of today’s students know much about typewriters and using monospaced fonts is not something many of them have ever done. Moving to proportional fonts for computers was a big deal back in the day. Type for printing presses has always (so far as I know) been proportional. It didn’t make sense to do otherwise. Typesetters used different sizes spaces to make sure things lined up they way they were supposed to line up. Using a computer with monospaced fonts it was pretty easy to line things up as well but the addition of good proportional fonts made things easier to read and nicer to look at but also make it very difficult to line things up at times.

Proportional fonts made the WYSIWYG editors and markup languages very important for getting good looking output. Students are used to these tools (some of them will eventually learn the LaTeX markup language) and use word processing tools regularly. We teach them about tab stops and other formatting tools. They’ll learn on their own that getting properly formatted output from programs they write themselves can get complicated. It’s probably good I give them some clues about that now.

No comments: