I use the new Canvas Text API, which---I guess---isn't supported by the iPhone. It would be fairly straightforward to make it use the old text API. I chose canvas as an output format for this demonstration, the algorithm itself knows nothing of canvas, so it could be adapted to use whatever output format is suitable for a device.