MCPcopy Create free account
hub / github.com/google/pprof / fitText

Function fitText

internal/driver/html/stacks.js:514–532  ·  view source on GitHub ↗
(t, avail, textList)

Source from the content-addressed store, hash-verified

512
513 // fitText sets text and font-size clipped to the specified width w.
514 function fitText(t, avail, textList) {
515 // Find first entry in textList that fits.
516 let width = avail;
517 textContext.font = FONT_SIZE + 'pt Arial';
518 for (let i = 0; i < textList.length; i++) {
519 let text = textList[i];
520 width = textContext.measureText(text).width;
521 if (width <= avail) {
522 t.innerText = text;
523 return;
524 }
525 }
526
527 // Try to fit by dropping font size.
528 let text = textList[textList.length-1];
529 const fs = Math.max(MIN_FONT_SIZE, FONT_SIZE * (avail / width));
530 t.style.fontSize = fs + 'pt';
531 t.innerText = text;
532 }
533
534 // totalValue returns the positive and negative sums of the Values of stacks
535 // listed in places.

Callers 1

drawBoxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…