Skip to content

Instantly share code, notes, and snippets.

@adambisek
Last active January 3, 2017 14:58
Show Gist options
  • Save adambisek/2f996dc418d18ae214ee4e0a0f2f84d1 to your computer and use it in GitHub Desktop.
Save adambisek/2f996dc418d18ae214ee4e0a0f2f84d1 to your computer and use it in GitHub Desktop.
var pixelWidth = require('string-pixel-width').default;
var width = pixelWidth('My text ...', { size: 10 });
console.log('This text has width ' + width + 'px in the size of 10px.');
// "This text has width 43.5px in the size of 10px."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment