var pixelWidth = require('string-pixel-width'); const width = pixelWidth('My text ...', { size: 10 }); console.log('This text is ' + width + 'px long in the size of ...