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.
font-details
Advanced tools
This package allows for easy testing of what size a string from a font will be when it is rendered
This package allows for easy testing of what size a string from a font will be when it is rendered
import { getFontDetails } from "font-details";
function main(): TextMetrics {
const details = getFontDetails(10, "monospace");
//Gets the details of "10px monospace" with the character 'a'
return details;
}
// Returns
{
"actualBoundingBoxAscent": 5,
"actualBoundingBoxDescent": 0,
"actualBoundingBoxLeft": 0,
"actualBoundingBoxRight": 5,
"fontBoundingBoxAscent": 9,
"fontBoundingBoxDescent": 3,
"width": 5.498046875
}
function getWidthExample(): number {
const details = getFontDetails(10, "monospace");
//Gets the details of "10px monospace" with the character 'a'
return details.width; // 5.498046875, in this case
}
The default string used for measuring text is simply "a"
function customStringExample(): number {
const details = getFontDetails(10, "monospace", "ab");
//Gets the details of "10px monospace" with the character 'a'
return details.width; // 10.99609375, in this case
}
As this font is monospace, the width of "ab" is double the width of "a", as each glyph has the same width. This isn't the case for most fonts, where different letters have different widths
If you like this package, leave it a star on github:
FAQs
This package allows for easy testing of what size a string from a font will be when it is rendered
The npm package font-details receives a total of 0 weekly downloads. As such, font-details popularity was classified as not popular.
We found that font-details 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.