Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
string-pixel-width
Advanced tools
String pixel width measurement on the backend in Javascript.
Why I created this package? Read more about purpose
To install the stable version:
npm install --save string-pixel-width
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 10px.');
// This text is 43.5px long in the size of 10px.
var pixelWidth = require('string-pixel-width');
const width = pixelWidth('My text ...', { font: 'impact', size: 10 });
console.log('This text is ' + width + 'px long in the size of 10px.');
// This text is 42px long in the size of 10px.
var pixelWidth = require('string-pixel-width');
const width = pixelWidth('My text ...', { font: 'open sans', size: 10, bold: true, italic: true });
console.log('This text is ' + width + 'px long in the size of 10px.');
// This text is 47px long in the size of 10px using bold and italic proportions.
PRs are welcome :) This library uses static map of width of every ASCII letter for all supported fonts.
src/pixelWidthCalculator.html
in your editorsrc/pixelWidthCalculator.html
in Google Chrome. It should look like this:
src/widthsMap.js
Please everytime make sure you don't broke existing fonts - remove any font or broke his widths.
FAQs
String pixel width measurement on the backend in Javascript
The npm package string-pixel-width receives a total of 14,086 weekly downloads. As such, string-pixel-width popularity was classified as popular.
We found that string-pixel-width demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.