MCPcopy
hub / github.com/aframevr/aframe / computeFontWidthFactor

Function computeFontWidthFactor

src/components/text.js:463–475  ·  view source on GitHub ↗

* Compute default font width factor to use.

(font)

Source from the content-addressed store, hash-verified

461 * Compute default font width factor to use.
462 */
463function computeFontWidthFactor (font) {
464 var sum = 0;
465 var digitsum = 0;
466 var digits = 0;
467 font.chars.forEach(function (ch) {
468 sum += ch.xadvance;
469 if (ch.id >= 48 && ch.id <= 57) {
470 digits++;
471 digitsum += ch.xadvance;
472 }
473 });
474 return digits ? digitsum / digits : sum / font.chars.length;
475}
476
477/**
478 * Get or create a promise given a key and promise generator.

Callers 1

text.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected