Monospace Fonts on iOS

December 20, 2010

Today I just had what might be my biggest disappointment of the year: monospace fonts are not monospaced on iOS. Specifically, the hyphen and question mark are wider than other characters in Courier New on iOS. Of course, this completely messes up any kind of monospace-based layout you might want to do.

Here are the alternatives I’ve investigated that didn’t work:

  1. Leaving the programming industry. Unfortunately, I’m not smart enough to do anything else. On to more reasonable alternatives.
  2. Tried other installed fonts. Courier is supported, but has the same problem. Monaco isn’t supported. And that’s all the built-in font options.
  3. Web fonts. I searched through the Google Font Directory and found “Droid Sans Mono.” If that had worked, man, what a slap in the face, huh? Unfortunately, it exhibited the same problem.

Here are options that could or did work:

  1. In app store apps, custom views to lay out text. If you draw one character at a time, you can make sure they’re placed properly. Unfortunately, if you need to use this for an editor (as I do), that would mean re-implementing a ton of functionality.
  2. On the web, replace dashes with HTML entities. This works for webapps and UIWebViews. If you replace all dashes/hyphens with –, you will see an identical (in Courier New) looking dash, that is spaced properly. This works for displaying text, but wouldn’t work for editors, which are just displaying bare characters and not interpreting HTML entities. Also, this doesn’t solve the question mark problem.

Does anyone else have any suggestions?


Follow

Get every new post delivered to your Inbox.

Join 525 other followers