伊地知ニジカ放送局だぬ゛ん゛. https://www.youtube.com/@deerjika
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common_module.py 342 B

12345678910111213
  1. import unicodedata
  2. class CommonModule:
  3. @staticmethod
  4. def is_wide (c: str) -> bool:
  5. return unicodedata.east_asian_width (c) in ['F', 'W', 'A']
  6. @classmethod
  7. def string_width_per_pt (cls, string: str) -> float:
  8. return sum ([1 if cls.is_wide (c) else .5
  9. for c in string.decode ('utf-8')])