{"library":"server-text-width","type":"library","category":null,"description":"server-text-width is a utility library designed for server-side environments, specifically Node.js, to accurately calculate the pixel width of text. Unlike browser-based solutions that leverage Canvas or DOM elements, this package operates without a browser environment by relying on pre-generated lookup tables. This capability is crucial for server-side rendering (SSR) scenarios where text needs to be trimmed, aligned, or used in layout calculations without client-side dependencies. The current stable version is 1.0.2, indicating a nascent but stable 1.x release series. Its key differentiators include zero runtime dependencies, full Unicode support, compatibility with custom fonts, and a highly compact base64 encoding for character width data. Developers must use an included `mappingTool.html` to generate these character width lookup tables for their specific fonts, sizes, and weights, which are then passed to the library's `init` function. This approach ensures consistent text measurement results across environments and allows for precise control over font metrics.","language":"javascript","status":"active","version":"1.0.2","tags":["javascript","typescript"],"install":[{"cmd":"npm install server-text-width","imports":["import { init } from 'server-text-width';","const { getTextWidth } = init(lookupTable);"]},{"cmd":"yarn add server-text-width","imports":[]},{"cmd":"pnpm add server-text-width","imports":[]}],"homepage":null,"github":"https://github.com/Evgenus/js-server-text-width","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/server-text-width","openapi_spec":null,"status_page":null,"smithery":null,"compatibility":{"summary":{"python_range":"18–22","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"url":"https://checklist.day/v1/registry/server-text-width/compatibility"},"provenance":{"verified_status":null,"verified_at":null,"last_verified":"Wed Jun 17","next_check":"Sat Jul 18","install_tag":null}}