Re:Show HN: Primrose – A text editor that draws to Canvas
by mattdesl on Wednesday January 07, 2015 @10:31AM
(#8850998)
Text in WebGL is still really immature.
I've done a bit of tinkering with a variety of modules for word-wrapping, etc. None of them are "fully featured" or 100% stable but I have used them in a couple of production environments.
The main issue I have with most text libraries (like TxtJS) is that they assume 2D canvas, or trivial WebGL applications. The bulk of the text code really just deals with laying out rectangular glyphs; the rendering (whether geometry, bitmaps, SDF, etc) should be separate so the dev can choose the best technique for their app.
I've done a bit of tinkering with a variety of modules for word-wrapping, etc. None of them are "fully featured" or 100% stable but I have used them in a couple of production environments.
https://github.com/mattdesl/fontpath
The WebGL module on top of that:
https://github.com/mattdesl/gl-sprite-text
The main issue I have with most text libraries (like TxtJS) is that they assume 2D canvas, or trivial WebGL applications. The bulk of the text code really just deals with laying out rectangular glyphs; the rendering (whether geometry, bitmaps, SDF, etc) should be separate so the dev can choose the best technique for their app.
An example of SDF / fontpath in action:
http://mattdesl.github.io/xmas