MCPcopy Index your code
hub / github.com/clips/pattern / textmetrics

Function textmetrics

pattern/canvas.js:2466–2477  ·  view source on GitHub ↗
(str, options)

Source from the content-addressed store, hash-verified

2464}
2465
2466function textmetrics(str, options) {
2467 /* Returns array [width, height] for the given text.
2468 */
2469 var a = _fontMixin(options);
2470 var w = 0;
2471 _ctx_font(a[0], a[1], a[2]);
2472 var lines = str.toString().split("\n");
2473 for (var i=0; i<lines.length; i++) {
2474 w = Math.max(w, _ctx.measureText(lines[i]).width);
2475 }
2476 return [w, a[1] + a[1]*a[3]*(lines.length-1)];
2477}
2478
2479function textwidth(str, options) {
2480 /* Returns the width of the given text.

Callers 2

textwidthFunction · 0.85
textheightFunction · 0.85

Calls 3

_fontMixinFunction · 0.85
_ctx_fontFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…