summaryrefslogtreecommitdiffstats
path: root/share/extensions
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-12-16 05:34:34 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-12-16 05:34:34 +0000
commit57b891d5c1f9e1bdf8cff9dc2b1cd3676d1d6762 (patch)
tree2465a81ad663ff9a85a3f8f02f191be60bfb6af4 /share/extensions
parentAdd extension 'Render > Hershey Text' for engraving fonts (diff)
downloadinkscape-57b891d5c1f9e1bdf8cff9dc2b1cd3676d1d6762.tar.gz
inkscape-57b891d5c1f9e1bdf8cff9dc2b1cd3676d1d6762.zip
Hershey Text: whitespace; py: docstring, modeline; inx: fix attribute value
(bzr r11687.1.2)
Diffstat (limited to 'share/extensions')
-rw-r--r--share/extensions/hershey.inx87
-rwxr-xr-xshare/extensions/hershey.py180
2 files changed, 136 insertions, 131 deletions
diff --git a/share/extensions/hershey.inx b/share/extensions/hershey.inx
index 3e14ee84f..1fa3938a4 100644
--- a/share/extensions/hershey.inx
+++ b/share/extensions/hershey.inx
@@ -1,60 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>Hershey Text</_name>
- <id>org.evilmad.render.hershe</id>
- <dependency type="executable" location="extensions">hershey.py</dependency>
- <dependency type="executable" location="extensions">hersheydata.py</dependency>
- <dependency type="executable" location="extensions">inkex.py</dependency>
+ <_name>Hershey Text</_name>
+ <id>org.evilmad.render.hershe</id>
+ <dependency type="executable" location="extensions">hershey.py</dependency>
+ <dependency type="executable" location="extensions">hersheydata.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
- <param name="tab" type="notebook">
+ <param name="tab" type="notebook">
<page name="splash" _gui-text="Render Text">
- <param name="text" type="string" _gui-text="Text:">Hershey Text for Inkscape</param>
+ <param name="text" type="string" _gui-text="Text:">Hershey Text for Inkscape</param>
- <param name="action" type="optiongroup" appearance="minimal"
- _gui-text=" Action">
- <_option value="render">Typeset that text</_option>
- <_option value="table" >Write glyph table</_option>
- </param>
+ <param name="action" type="optiongroup" appearance="minimal"
+ _gui-text=" Action">
+ <_option value="render">Typeset that text</_option>
+ <_option value="table" >Write glyph table</_option>
+ </param>
- <param name="fontface" type="optiongroup" appearance="minimal"
- _gui-text=" Font face ">
- <_option value="futural">Sans 1-stroke</_option>
- <_option value="futuram">Sans bold</_option>
+ <param name="fontface" type="optiongroup" appearance="minimal"
+ _gui-text=" Font face ">
+ <_option value="futural">Sans 1-stroke</_option>
+ <_option value="futuram">Sans bold</_option>
- <_option value="timesr">Serif medium</_option>
- <_option value="timesi">Serif medium italic</_option>
- <_option value="timesib">Serif bold italic</_option>
- <_option value="timesrb">Serif bold</_option>
+ <_option value="timesr">Serif medium</_option>
+ <_option value="timesi">Serif medium italic</_option>
+ <_option value="timesib">Serif bold italic</_option>
+ <_option value="timesrb">Serif bold</_option>
- <_option value="scripts">Script 1-stroke</_option>
- <_option value="cursive">Script 1-stroke (alt)</_option>
- <_option value="scriptc">Script medium</_option>
+ <_option value="scripts">Script 1-stroke</_option>
+ <_option value="cursive">Script 1-stroke (alt)</_option>
+ <_option value="scriptc">Script medium</_option>
- <_option value="gothiceng">Gothic English</_option>
- <_option value="gothicger">Gothic German</_option>
- <_option value="gothicita">Gothic Italian</_option>
+ <_option value="gothiceng">Gothic English</_option>
+ <_option value="gothicger">Gothic German</_option>
+ <_option value="gothicita">Gothic Italian</_option>
- <_option value="greek">Greek 1-stroke</_option>
- <_option value="timesg">Greek medium</_option>
- <_option value="cyrillic">Cyrillic</_option>
- <_option value="japanese">Japanese</_option>
+ <_option value="greek">Greek 1-stroke</_option>
+ <_option value="timesg">Greek medium</_option>
+ <_option value="cyrillic">Cyrillic</_option>
+ <_option value="japanese">Japanese</_option>
- <_option value="astrology">Astrology</_option>
- <_option value="mathlow">Math (lower)</_option>
- <_option value="mathupp">Math (upper)</_option>
- <_option value="markers">Markers</_option>
- <_option value="meteorology">Meteorology</_option>
- <_option value="music">Music</_option>
- <_option value="symbolic">Symbolic</_option>
+ <_option value="astrology">Astrology</_option>
+ <_option value="mathlow">Math (lower)</_option>
+ <_option value="mathupp">Math (upper)</_option>
+ <_option value="markers">Markers</_option>
+ <_option value="meteorology">Meteorology</_option>
+ <_option value="music">Music</_option>
+ <_option value="symbolic">Symbolic</_option>
- </param>
- <_param name="emptyspace" type="description" xml:space="preserve">
+ </param>
+ <_param name="emptyspace" type="description" xml:space="preserve">
</_param>
- </page>
+ </page>
<page name="info" _gui-text="About...">
<_param name="aboutpage" type="description" xml:space="preserve">
This extension renders a line of text using
@@ -70,18 +70,17 @@ but are instead "single-stroke" fonts, or
formed by the stroke (and not the fill).
For additional information, please visit:
- www.evilmadscientist.com/go/hershey
-</_param>
+ www.evilmadscientist.com/go/hershey</_param>
</page>
</param>
- <effect needs-live-preview="true" needs-document="no">
+ <effect needs-live-preview="true" needs-document="true">
<object-type>all</object-type>
<effects-menu>
<submenu _name="Render"/>
</effects-menu>
</effect>
<script>
- <command reldir="extensions" interpreter="python">hershey.py</command>
+ <command reldir="extensions" interpreter="python">hershey.py</command>
</script>
</inkscape-extension>
diff --git a/share/extensions/hershey.py b/share/extensions/hershey.py
index 137b258e8..931e5f337 100755
--- a/share/extensions/hershey.py
+++ b/share/extensions/hershey.py
@@ -1,99 +1,104 @@
-# Copyright 2011, Windell H. Oskay, www.evilmadscientist.com
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import hersheydata #data file w/ Hershey font data
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+Hershey Text - renders a line of text using "Hershey" fonts for plotters
+
+Copyright 2011, Windell H. Oskay, www.evilmadscientist.com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+import hersheydata #data file w/ Hershey font data
import inkex
import simplestyle
Debug = False
def draw_svg_text(char, face, offset, vertoffset, parent):
- style = { 'stroke': '#000000', 'fill': 'none' }
- pathString = face[char]
- splitString = pathString.split()
- midpoint = offset - int(splitString[0])
- pathString = pathString[pathString.find("M"):] #portion after first move
- trans = 'translate(' + str(midpoint) + ',' + str(vertoffset) + ')'
- text_attribs = {'style':simplestyle.formatStyle(style), 'd':pathString, 'transform':trans}
- inkex.etree.SubElement(parent, inkex.addNS('path','svg'), text_attribs)
- return midpoint + int(splitString[1]) #new offset value
+ style = { 'stroke': '#000000', 'fill': 'none' }
+ pathString = face[char]
+ splitString = pathString.split()
+ midpoint = offset - int(splitString[0])
+ pathString = pathString[pathString.find("M"):] #portion after first move
+ trans = 'translate(' + str(midpoint) + ',' + str(vertoffset) + ')'
+ text_attribs = {'style':simplestyle.formatStyle(style), 'd':pathString, 'transform':trans}
+ inkex.etree.SubElement(parent, inkex.addNS('path','svg'), text_attribs)
+ return midpoint + int(splitString[1]) #new offset value
class Hershey( inkex.Effect ):
- def __init__( self ):
- inkex.Effect.__init__( self )
- self.OptionParser.add_option( "--tab", #NOTE: value is not used.
- action="store", type="string",
- dest="tab", default="splash",
- help="The active tab when Apply was pressed" )
- self.OptionParser.add_option( "--text",
- action="store", type="string",
- dest="text", default="Hershey Text for Inkscape",
- help="The input text to render")
- self.OptionParser.add_option( "--action",
- action="store", type="string",
- dest="action", default="render",
- help="The active option when Apply was pressed" )
- self.OptionParser.add_option( "--fontface",
- action="store", type="string",
- dest="fontface", default="rowmans",
- help="The selected font face when Apply was pressed" )
-
- def effect( self ):
-
- # Embed text in group to make manipulation easier:
- g_attribs = {inkex.addNS('label','inkscape'):'Hershey Text' }
- g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
-
- font = eval('hersheydata.' + str(self.options.fontface))
- clearfont = hersheydata.futural
- #Baseline: modernized roman simplex from JHF distribution.
-
- w = 0 #Initial spacing offset
- spacing = 3 # spacing between letters
-
- if self.options.action == "render":
- #evaluate text string
- letterVals = [ord(q) - 32 for q in self.options.text]
- for q in letterVals:
- if (q < 0) or (q > 95):
- w += 2*spacing
- else:
- w = draw_svg_text(q, font, w, 0, g)
- else:
- #Generate glyph table
- wmax = 0;
- for p in range(0,10):
- w = 0
- v = spacing * (15*p - 67 )
- for q in range(0,10):
- r = p*10 + q
- if (r < 0) or (r > 95):
- w += 5*spacing
- else:
- w = draw_svg_text(r, clearfont, w, v, g)
- w = draw_svg_text(r, font, w, v, g)
- w += 5*spacing
- if w > wmax:
- wmax = w
- w = wmax
-
- # Translate group to center of view, approximately
- t = 'translate(' + str( self.view_center[0] - w/2) + ',' + str( self.view_center[1] ) + ')'
- g.set( 'transform',t)
+ def __init__( self ):
+ inkex.Effect.__init__( self )
+ self.OptionParser.add_option( "--tab", #NOTE: value is not used.
+ action="store", type="string",
+ dest="tab", default="splash",
+ help="The active tab when Apply was pressed" )
+ self.OptionParser.add_option( "--text",
+ action="store", type="string",
+ dest="text", default="Hershey Text for Inkscape",
+ help="The input text to render")
+ self.OptionParser.add_option( "--action",
+ action="store", type="string",
+ dest="action", default="render",
+ help="The active option when Apply was pressed" )
+ self.OptionParser.add_option( "--fontface",
+ action="store", type="string",
+ dest="fontface", default="rowmans",
+ help="The selected font face when Apply was pressed" )
+
+ def effect( self ):
+
+ # Embed text in group to make manipulation easier:
+ g_attribs = {inkex.addNS('label','inkscape'):'Hershey Text' }
+ g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
+
+ font = eval('hersheydata.' + str(self.options.fontface))
+ clearfont = hersheydata.futural
+ #Baseline: modernized roman simplex from JHF distribution.
+
+ w = 0 #Initial spacing offset
+ spacing = 3 # spacing between letters
+
+ if self.options.action == "render":
+ #evaluate text string
+ letterVals = [ord(q) - 32 for q in self.options.text]
+ for q in letterVals:
+ if (q < 0) or (q > 95):
+ w += 2*spacing
+ else:
+ w = draw_svg_text(q, font, w, 0, g)
+ else:
+ #Generate glyph table
+ wmax = 0;
+ for p in range(0,10):
+ w = 0
+ v = spacing * (15*p - 67 )
+ for q in range(0,10):
+ r = p*10 + q
+ if (r < 0) or (r > 95):
+ w += 5*spacing
+ else:
+ w = draw_svg_text(r, clearfont, w, v, g)
+ w = draw_svg_text(r, font, w, v, g)
+ w += 5*spacing
+ if w > wmax:
+ wmax = w
+ w = wmax
+
+ # Translate group to center of view, approximately
+ t = 'translate(' + str( self.view_center[0] - w/2) + ',' + str( self.view_center[1] ) + ')'
+ g.set( 'transform',t)
@@ -101,3 +106,4 @@ if __name__ == '__main__':
e = Hershey()
e.affect()
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99