Code

New extension to convert text to braille
authorJucaBlues <JucaBlues@users.sourceforge.net>
Tue, 4 Mar 2008 07:48:35 +0000 (07:48 +0000)
committerJucaBlues <JucaBlues@users.sourceforge.net>
Tue, 4 Mar 2008 07:48:35 +0000 (07:48 +0000)
share/extensions/Makefile.am
share/extensions/text_braille.inx [new file with mode: 0644]
share/extensions/text_braille.py [new file with mode: 0644]

index 100b906fc56337220b81b3c25c86b308e6d45c2e..6ad2f17f30122ad8fe636689ebc4628a3bf7986f 100644 (file)
@@ -98,6 +98,7 @@ extensions = \
        text_flipcase.py \
        text_randomcase.py \
        text_replace.py \
+       text_braille.py \
        txt2svg.pl \
        webbrowser_askaquestion.py \
        webbrowser_commandline.py \
@@ -206,6 +207,7 @@ modules = \
        text_flipcase.inx \
        text_randomcase.inx \
        text_replace.inx \
+       text_braille.inx \   
        txt2svg.inx \
        whirl.inx \
        wmf_input.inx \
diff --git a/share/extensions/text_braille.inx b/share/extensions/text_braille.inx
new file mode 100644 (file)
index 0000000..1bd0357
--- /dev/null
@@ -0,0 +1,15 @@
+<inkscape-extension>\r
+       <_name>Convert to Braille</_name>\r
+       <id>org.inkscape.text.braille</id>\r
+       <dependency type="executable" location="extensions">chardataeffect.py</dependency>\r
+       <dependency type="executable" location="extensions">text_braille.py</dependency>\r
+       <effect>\r
+               <object-type>all</object-type>\r
+               <effects-menu>\r
+                       <submenu _name="Text"/>\r
+               </effects-menu>\r
+       </effect>\r
+       <script>\r
+               <command reldir="extensions" interpreter="python">text_braille.py</command>\r
+       </script>\r
+</inkscape-extension>\r
diff --git a/share/extensions/text_braille.py b/share/extensions/text_braille.py
new file mode 100644 (file)
index 0000000..5de3538
--- /dev/null
@@ -0,0 +1,45 @@
+#encoding: utf-8
+import chardataeffect, inkex, string\r
+
+convert_table = {\
+'a': unicode("⠁", "utf-8"),\
+'b': unicode("⠃", "utf-8"),\
+'c': unicode("⠉", "utf-8"),\
+'d': unicode("⠙", "utf-8"),\
+'e': unicode("⠑", "utf-8"),\
+'f': unicode("⠋", "utf-8"),\
+'g': unicode("⠛", "utf-8"),\
+'h': unicode("⠓", "utf-8"),\
+'i': unicode("⠊", "utf-8"),\
+'j': unicode("⠚", "utf-8"),\
+'k': unicode("⠅", "utf-8"),\
+'l': unicode("⠇", "utf-8"),\
+'m': unicode("⠍", "utf-8"),\
+'n': unicode("⠝", "utf-8"),\
+'o': unicode("⠕", "utf-8"),\
+'p': unicode("⠏", "utf-8"),\
+'q': unicode("⠟", "utf-8"),\
+'r': unicode("⠗", "utf-8"),\
+'s': unicode("⠎", "utf-8"),\
+'t': unicode("⠞", "utf-8"),\
+'u': unicode("⠥", "utf-8"),\
+'v': unicode("⠧", "utf-8"),\
+'w': unicode("⠺", "utf-8"),\
+'x': unicode("⠭", "utf-8"),\
+'y': unicode("⠽", "utf-8"),\
+'z': unicode("⠵", "utf-8"),\
+}
+
+class C(chardataeffect.CharDataEffect):\r
+\r
+  def process_chardata(self,text, line, par):\r
+    r = ""\r
+    for c in text:
+      if convert_table.has_key(c.lower()):\r
+        r = r + convert_table[c.lower()]\r
+      else:\r
+        r = r + c\r
+    return r
+\r
+c = C()\r
+c.affect()\r