openlayers/ol3 — pull request #1586 by twpayne (2014-01-23 14:51:35+00:00)
Title: Add text rendering

This is a work in progress, probably not ready to be merged yet, but ready for initial review and testing. It adds text rendering to both replay and immediate modes. Text is automatically scaled for Hi-DPI devices and can be rotated.

![ol3-text](https://f.cloud.github.com/assets/6942/1985404/b9c1ca68-843d-11e3-8535-b3b1ea49b34b.png)

Handling text in canvas is fairly complicated, because the same canvas context state (stroke and fill styles) is needed for both text and geometries, whereas these are separate in the way ol3 defines styles. This means that there is a large amount of coupled state in the canvas context to manage. Although I have tried to use the compiler's type checking to help catch errors, it is likely that a few corner case errors have crept in.

Remaining tasks include:

- [ ] Refactor `ol.render.canvas.LineStringReplay` to use the new context state management architecture
- [ ] Refactor `ol.render.canvas.PolygonReplay` to use the new context state management architecture
- [ ] Refactor `ol.render.canvas.ImageReplay` to be more consistent with the other `o*Replay` classes
- [ ] Factor out common code between `ol.render.canvas.Immediate` and `ol.render.canvas.*Replay`
- [ ] Add option to specify that text should be rotated relative to the map rather than the viewport
- [ ] Possibly split `ol.style.Text#font` into separate `fontSize` and `fontFamily` properties

Note that the first four of these will not affect the API.