Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string-display-width

kdong00729MIT1.0.1

approximate string's display without actual rendering

string, display, width

readme

string-display-width

approximate string's display without actual rendering (based on PingFang SC right now)

install

npm install string-display-width --save
yarn add string-display-width

import

import stringDisplayWidth from "string-display-width";

api

stringDisplayWidth(str, fontSize, fontWeight)

  • str, the string your want to meausre
  • fontSize, the display font size
  • fontWeight, "regular"|"medium"|"semiBold", default "regular"