adambisek / String Pixel Width
Blazingly fast measure string width in pixels on the server in Javascript (Node.Js)
Stars: ✭ 65
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to String Pixel Width
String
Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way.
Stars: ✭ 709 (+990.77%)
Mutual labels: string
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-46.15%)
Mutual labels: string
Cape
String encryption for Arduino, limited microcontrollers and other embedded systems.
Stars: ✭ 58 (-10.77%)
Mutual labels: string
Javascript Obfuscator
A powerful obfuscator for JavaScript and Node.js
Stars: ✭ 8,204 (+12521.54%)
Mutual labels: string
Tinystr
A small ASCII-only bounded length string representation.
Stars: ✭ 48 (-26.15%)
Mutual labels: string
Python String Similarity
A library implementing different string similarity and distance measures using Python.
Stars: ✭ 546 (+740%)
Mutual labels: string
String Interner
A data structure to efficiently intern, cache and restore strings.
Stars: ✭ 60 (-7.69%)
Mutual labels: string
Arccstr
Thread-safe, reference-counted null-terminated immutable Rust strings.
Stars: ✭ 34 (-47.69%)
Mutual labels: string
Stringplus
Funny and minimal string library for C++ inspired by underscore.string
Stars: ✭ 7 (-89.23%)
Mutual labels: string
Php Confusable Homoglyphs
A PHP port of https://github.com/vhf/confusable_homoglyphs
Stars: ✭ 27 (-58.46%)
Mutual labels: string
Str
A SIMD optimized fixed-length string class along with an adaptive hash table for fast searching
Stars: ✭ 60 (-7.69%)
Mutual labels: string
Unitsnet
Makes life working with units of measurement just a little bit better.
Stars: ✭ 641 (+886.15%)
Mutual labels: measure
Litestringbuilder
Alternative to the System.Text.StringBuilder C# class.
Stars: ✭ 48 (-26.15%)
Mutual labels: string
Fuzzy Swift
🔍 simple and fast fuzzy string matching in Swift
Stars: ✭ 61 (-6.15%)
Mutual labels: string
String Calc
PHP calculator library for mathematical terms (expressions) passed as strings
Stars: ✭ 60 (-7.69%)
Mutual labels: string
Golang Combinations
Golang library which provide an algorithm to generate all combinations out of a given string array.
Stars: ✭ 51 (-21.54%)
Mutual labels: string
string-pixel-width
String pixel width measurement on the backend in Javascript.
Why I created this package? Read more about purpose
Installation
To install the stable version:
npm install --save string-pixel-width
Supported fonts:
- Andale Mono
- Arial
- Avenir
- Avenir Next
- Comic Sans MS
- Courier New
- Georgia
- Helvetica
- Impact
- Times New Roman
- Trebuchet MS
- Verdana
- Webdings
- Open Sans
- Tahoma
Example
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.
How to contribute
PRs are welcome :) This library uses static map of width of every ASCII letter for all supported fonts.
- Clone the repository
- Open file
src/pixelWidthCalculator.html
in your editor - Add your font name into array of fonts (currently var websafe) and save
- Open up
src/pixelWidthCalculator.html
in Google Chrome. It should look like this: - Map of withs will be generated for you - copy it and replace content of file
src/widthsMap.js
Please everytime make sure you don't broke existing fonts - remove any font or broke his widths.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].