{"id":13515410,"url":"https://github.com/adambisek/string-pixel-width","last_synced_at":"2025-03-31T04:37:00.944Z","repository":{"id":15323423,"uuid":"77859334","full_name":"adambisek/string-pixel-width","owner":"adambisek","description":"Blazingly fast measure string width in pixels on the server in Javascript (Node.Js)","archived":false,"fork":false,"pushed_at":"2023-08-09T05:54:45.000Z","size":440,"stargazers_count":101,"open_issues_count":22,"forks_count":42,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-10T16:32:01.729Z","etag":null,"topics":["javascript","measure","nodejs","string","width"],"latest_commit_sha":null,"homepage":"https://medium.com/@adambisek/text-pixel-width-measuring-on-javascript-backend-node-js-2b82bea97fab#.8ypyiffyw","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adambisek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-01-02T20:17:11.000Z","updated_at":"2024-03-18T06:59:41.000Z","dependencies_parsed_at":"2023-10-20T16:19:44.306Z","dependency_job_id":null,"html_url":"https://github.com/adambisek/string-pixel-width","commit_stats":{"total_commits":46,"total_committers":10,"mean_commits":4.6,"dds":0.5652173913043479,"last_synced_commit":"cd58ff41c9cacf74a6e2af4699dc0c8947bc8ba4"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambisek%2Fstring-pixel-width","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambisek%2Fstring-pixel-width/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambisek%2Fstring-pixel-width/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambisek%2Fstring-pixel-width/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adambisek","download_url":"https://codeload.github.com/adambisek/string-pixel-width/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418657,"owners_count":20773934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","measure","nodejs","string","width"],"created_at":"2024-08-01T05:01:10.943Z","updated_at":"2025-03-31T04:36:59.146Z","avatar_url":"https://github.com/adambisek.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[string-pixel-width](https://github.com/adambisek/string-pixel-width)\n===================================\n[![Build Status](https://travis-ci.org/adambisek/string-pixel-width.svg?branch=master)](https://travis-ci.org/adambisek/string-pixel-width)\n[![npm version](https://img.shields.io/npm/v/string-pixel-width.svg?style=flat-square)](https://www.npmjs.com/package/string-pixel-width)\n[![Coverage Status](https://coveralls.io/repos/github/adambisek/string-pixel-width/badge.svg?branch=master)](https://coveralls.io/github/adambisek/string-pixel-width?branch=master)\n\nString pixel width measurement on the backend in Javascript.\n\n[Why I created this package? Read more about purpose](https://medium.com/@adambisek/text-pixel-width-measuring-on-javascript-backend-node-js-2b82bea97fab#.8ypyiffyw)\n\nInstallation\n------------\nTo install the stable version:\n\n\u003ccode\u003e\nnpm install --save string-pixel-width\n\u003c/code\u003e\n\nSupported fonts:\n------------\n\n- Andale Mono\n- Arial\n- Avenir\n- Avenir Next\n- Comic Sans MS\n- Courier New\n- Georgia\n- Helvetica\n- Impact\n- Inter\n- Times New Roman\n- Trebuchet MS\n- Verdana\n- Webdings\n- Open Sans\n- Tahoma\n\nExample\n------------\n```\nvar pixelWidth = require('string-pixel-width');\n\nconst width = pixelWidth('My text ...', { size: 10 });\nconsole.log('This text is ' + width + 'px long in the size of 10px.');\n\n// This text is 43.5px long in the size of 10px.\n```\n\n```\nvar pixelWidth = require('string-pixel-width');\n\nconst width = pixelWidth('My text ...', { font: 'impact', size: 10 });\nconsole.log('This text is ' + width + 'px long in the size of 10px.');\n\n// This text is 42px long in the size of 10px.\n```\n\n```\nvar pixelWidth = require('string-pixel-width');\n\nconst width = pixelWidth('My text ...', { font: 'open sans', size: 10, bold: true, italic: true });\nconsole.log('This text is ' + width + 'px long in the size of 10px.');\n\n// This text is 47px long in the size of 10px using bold and italic proportions.\n```\n\nHow to contribute\n------------\nPRs are welcome :)\nThis library uses static map of width of every ASCII letter for all supported fonts.\n\n1. Clone the repository\n2. Open file ```src/pixelWidthCalculator.html``` in your editor\n3. Add your font name into array of fonts (currently var websafe) and save\n4. Open up ```src/pixelWidthCalculator.html``` in Google Chrome. It should look like this:\n![PHPStan](docs/string-pixel-width-1.png)\n5. Map of withs will be generated for you - copy it and replace content of file ```src/widthsMap.js```\n\n**Please everytime make sure you don't broke existing fonts - remove any font or broke his widths.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadambisek%2Fstring-pixel-width","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadambisek%2Fstring-pixel-width","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadambisek%2Fstring-pixel-width/lists"}