def cjkcutlen()

in Stable-Diffusion-UI-Agones/sd-webui/extensions/simple-files/scripts/simple_files.py [0:0]


def cjkcutlen(s, direction, width):
  w = 0
  if direction >= 0:
    for p, c in enumerate(s):
      w += 1 + (unicodedata.east_asian_width(c) in 'WF')
      if w + 1 > width:
        return s[0:p]
  else:
    for p, c in enumerate(reversed(s)):
      w += 1 + (unicodedata.east_asian_width(c) in 'WF')
      if w +1  > width:
        if p ==0:
          return ""
        return s[-p:]