Based on a post "Replacing Photoshop With NSString" seen on HN. I recommend you read that post first.
I have extended the initial ruleset so that at larger sizes simpler ascii arts can be used.
The rules are:
Here is an interactive space you can tryout.
There are two boolean properties added to the context ctx.iconAutoLineWidth and ctx.iconDebug. These are editable below.
Auto line width. Use the size of the 'grid' or use the context linewidth. Defaults to true.
Show debug lines if the grid size is greater than 5px. (this prevents drawing a black messy blob). Defaults to false
Width in px (0 for auto): Should be bigger than the columns of the text. Height is derived from the number of rows.
Great care has been given to ensure that the results are pixel aligned for nice crisp images.
Drawings are made to a canvas using the normal context methods. You can change the line drawing methods using the normal ctx.lineJoin and ctx.lineCap. As well as changing colour with ctx.fillColor and ctx.strokeColor which makes layering easier for multi coloured icons.
Width size set to auto the result should be pixel accurate. Sizes between 1 and the actual size might fail to render.