- From: Charles Pritchard <chuck@jumis.com>
- Date: Fri, 16 Dec 2011 12:39:22 -0800
Date: Fri, 16 Dec 2011 12:33:58 -0500 From: Francis Boumphrey<boumphreyfr@gmail.com> Message-ID: <CAN1jwS41BvJ-4MDX0vcZW-e_A0WZyzxh6=uzivQStR_bdecbXQ at mail.gmail.com> FTR, as an implementer, I find maxWidth very useful for the reasons Ian mentioned Frank B0umphrey ------ Frank, what do you mean by implementer? From a developers perspective, I certainly understand that maxWidth saves a few lines of code; function scaleDown(ctx, str, maxWidth, font, size) { while(ctx.measureText(str).width> maxWidth) { size -= 2; ctx.font = size + 'px ' + font; } // associated fill/stroke if wanted. } But that's all it does. It's not implemented widely, it gives the illusion of being complete. The resulting font size is not exposed to the author and may be too small to be legible by the viewer. There's no programmatic way to check for that. Unless you just implement it yourself, in a few lines of code, which is rather easy to do. While we could add a ctx.measureText(str, maxWidth) feature, it seems an unnecessary complication. If you're using text with Canvas, you ought to be using some smart methods and considering the minimum font size, and what should be done with the overflow (such as doing word wrapping). There's a long history of being conservative with the scope of the Canvas API. I still do not believe that maxWidth meets the criteria for a necessary feature. It's very easy to implement it in JS, with the added benefit of having size data exposed. -Charles
Received on Friday, 16 December 2011 12:39:22 UTC