|
@@ -0,0 +1,13 @@ |
|
|
|
|
|
import unicodedata |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CommonModule: |
|
|
|
|
|
@staticmethod |
|
|
|
|
|
def is_wide (c: str) -> bool: |
|
|
|
|
|
return unicodedata.east_asian_width (c) in ['F', 'W', 'A'] |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def string_width_per_pt (cls, string: str) -> float: |
|
|
|
|
|
return sum ([1 if cls.is_wide (c) else .5 |
|
|
|
|
|
for c in string.decode ('utf-8')]) |
|
|
|
|
|
|