Code

New extension to convert text to braille
[inkscape.git] / share / extensions / text_braille.py
1 #encoding: utf-8
2 import chardataeffect, inkex, string\r
4 convert_table = {\
5 'a': unicode("⠁", "utf-8"),\
6 'b': unicode("⠃", "utf-8"),\
7 'c': unicode("⠉", "utf-8"),\
8 'd': unicode("⠙", "utf-8"),\
9 'e': unicode("⠑", "utf-8"),\
10 'f': unicode("⠋", "utf-8"),\
11 'g': unicode("⠛", "utf-8"),\
12 'h': unicode("⠓", "utf-8"),\
13 'i': unicode("⠊", "utf-8"),\
14 'j': unicode("⠚", "utf-8"),\
15 'k': unicode("⠅", "utf-8"),\
16 'l': unicode("⠇", "utf-8"),\
17 'm': unicode("⠍", "utf-8"),\
18 'n': unicode("⠝", "utf-8"),\
19 'o': unicode("⠕", "utf-8"),\
20 'p': unicode("⠏", "utf-8"),\
21 'q': unicode("⠟", "utf-8"),\
22 'r': unicode("⠗", "utf-8"),\
23 's': unicode("⠎", "utf-8"),\
24 't': unicode("⠞", "utf-8"),\
25 'u': unicode("⠥", "utf-8"),\
26 'v': unicode("⠧", "utf-8"),\
27 'w': unicode("⠺", "utf-8"),\
28 'x': unicode("⠭", "utf-8"),\
29 'y': unicode("⠽", "utf-8"),\
30 'z': unicode("⠵", "utf-8"),\
31 }
33 class C(chardataeffect.CharDataEffect):\r
34 \r
35   def process_chardata(self,text, line, par):\r
36     r = ""\r
37     for c in text:
38       if convert_table.has_key(c.lower()):\r
39         r = r + convert_table[c.lower()]\r
40       else:\r
41         r = r + c\r
42     return r
43 \r
44 c = C()\r
45 c.affect()\r