File: text_titlecase.py

package info (click to toggle)
inkscape 0.47.0-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 122,072 kB
  • ctags: 46,938
  • sloc: cpp: 349,791; ansic: 31,306; python: 14,868; xml: 6,613; sh: 5,041; makefile: 1,773; perl: 1,486; asm: 675; ruby: 148
file content (28 lines) | stat: -rw-r--r-- 572 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import chardataeffect, inkex, string

class C(chardataeffect.CharDataEffect):

  word_ended = True

  def process_chardata(self,text, line, par):
    r = ""
    for i in range(len(text)):
      c = text[i]
      if c.isspace() or line == True or par == True:
        self.word_ended = True
      if not c.isspace():
        line = False
        par = False

      if self.word_ended and c.isalpha():
        r = r + c.upper()
        self.word_ended = False
      elif c.isalpha():
        r = r + c.lower()
      else:
        r = r + c

    return r

c = C()
c.affect()