Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.