diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2014-10-10 14:32:35 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2014-10-10 14:32:35 +0000 |
| commit | cc1b3bd8508b4b4e53683ca7c0e339cc124c542c (patch) | |
| tree | addb8720f096b078a47289f20658e5e977c0b6db /share | |
| parent | packaging scripts: fix syntax (diff) | |
| parent | Apply cx, cy, etc. from template to newly created document window. (diff) | |
| download | inkscape-cc1b3bd8508b4b4e53683ca7c0e339cc124c542c.tar.gz inkscape-cc1b3bd8508b4b4e53683ca7c0e339cc124c542c.zip | |
update to trunk (r13586)
(bzr r13506.1.111)
Diffstat (limited to 'share')
| -rw-r--r-- | share/extensions/empty_page.py | 77 | ||||
| -rw-r--r-- | share/extensions/setup_typography_canvas.inx | 10 | ||||
| -rwxr-xr-x | share/extensions/setup_typography_canvas.py | 7 |
3 files changed, 59 insertions, 35 deletions
diff --git a/share/extensions/empty_page.py b/share/extensions/empty_page.py index dc16bab97..34dee7fc4 100644 --- a/share/extensions/empty_page.py +++ b/share/extensions/empty_page.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +# Rewritten by Tavmjong Bah to add correct viewBox, inkscape:cx, etc. attributes + import inkex class C(inkex.Effect): @@ -8,37 +10,52 @@ class C(inkex.Effect): self.OptionParser.add_option("-s", "--size", action="store", type="string", dest="page_size", default="a4", help="Page size") self.OptionParser.add_option("-o", "--orientation", action="store", type="string", dest="page_orientation", default="vertical", help="Page orientation") - def effect(self): + def effect(self): + + width = 300 + height = 300 + units = 'px' + + if self.options.page_size == "a5": + width = 148 + height= 210 + units = 'mm' + + if self.options.page_size == "a4": + width = 210 + height= 297 + units = 'mm' + + if self.options.page_size == "a3": + width = 297 + height= 420 + units = 'mm' + + if self.options.page_size == "letter": + width = 8.5 + height = 11 + units = 'in' + + if self.options.page_orientation == "horizontal": + width, height = height, width + + root = self.document.getroot() - root.set("width", "12in") - root.set("height", "12in") - if self.options.page_size == "a4" and self.options.page_orientation == "vertical": - root.set("width", "210mm") - root.set("height", "297mm") - if self.options.page_size == "a4" and self.options.page_orientation == "horizontal": - root.set("height", "210mm") - root.set("width", "297mm") - - if self.options.page_size == "a5" and self.options.page_orientation == "vertical": - root.set("width", "148mm") - root.set("height", "210mm") - if self.options.page_size == "a5" and self.options.page_orientation == "horizontal": - root.set("width", "210mm") - root.set("height", "148mm") - - if self.options.page_size == "a3" and self.options.page_orientation == "vertical": - root.set("width", "297mm") - root.set("height", "420mm") - if self.options.page_size == "a3" and self.options.page_orientation == "horizontal": - root.set("width", "420mm") - root.set("height", "297mm") - - if self.options.page_size == "letter" and self.options.page_orientation == "vertical": - root.set("width", "8.5in") - root.set("height", "11in") - if self.options.page_size == "letter" and self.options.page_orientation == "horizontal": - root.set("width", "11in") - root.set("height", "8.5in") + root.set("id", "SVGRoot") + root.set("width", str(width) + units) + root.set("height", str(height) + units) + root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) + + namedview = root.find(inkex.addNS('namedview', 'sodipodi')) + if namedview is None: + namedview = inkex.etree.SubElement( root, inkex.addNS('namedview', 'sodipodi') ); + + namedview.set(inkex.addNS('document-units', 'inkscape'), units) + + # Until units are supported in 'cx', etc. + namedview.set(inkex.addNS('cx', 'inkscape'), str(self.uutounit( width, 'px' )/2.0 ) ) + namedview.set(inkex.addNS('cy', 'inkscape'), str(self.uutounit( height, 'px' )/2.0 ) ) + c = C() c.affect() diff --git a/share/extensions/setup_typography_canvas.inx b/share/extensions/setup_typography_canvas.inx index 332a14ade..8e7739b5c 100644 --- a/share/extensions/setup_typography_canvas.inx +++ b/share/extensions/setup_typography_canvas.inx @@ -4,11 +4,11 @@ <id>org.inkscape.typography.setuptypographycanvas</id> <dependency type="executable" location="extensions">inkex.py</dependency> <dependency type="executable" location="extensions">setup_typography_canvas.py</dependency> - <param name="emsize" type="int" _gui-text="Em-size:" min="10" max="2000">1000</param> - <param name="ascender" type="int" _gui-text="Ascender:" min="0" max="2000">750</param> - <param name="caps" type="int" _gui-text="Caps Height:" min="0" max="2000">700</param> - <param name="xheight" type="int" _gui-text="X-Height:" min="0" max="2000">500</param> - <param name="descender" type="int" _gui-text="Descender:" min="0" max="1000">250</param> + <param name="emsize" type="int" _gui-text="Em-size:" min="10" max="2048">1000</param> + <param name="ascender" type="int" _gui-text="Ascender:" min="0" max="2048">750</param> + <param name="caps" type="int" _gui-text="Caps Height:" min="0" max="2048">700</param> + <param name="xheight" type="int" _gui-text="X-Height:" min="0" max="2048">500</param> + <param name="descender" type="int" _gui-text="Descender:" min="0" max="1024">250</param> <effect> <object-type>all</object-type> <effects-menu> diff --git a/share/extensions/setup_typography_canvas.py b/share/extensions/setup_typography_canvas.py index 197aeb77e..a1000f2d1 100755 --- a/share/extensions/setup_typography_canvas.py +++ b/share/extensions/setup_typography_canvas.py @@ -69,6 +69,7 @@ class SetupTypographyCanvas(inkex.Effect): self.svg = self.document.getroot() self.svg.set("width", str(emsize)) self.svg.set("height", str(emsize)) + self.svg.set("viewBox", "0 0 " + str(emsize) + " " + str(emsize) ) baseline = descender # Create guidelines @@ -78,6 +79,12 @@ class SetupTypographyCanvas(inkex.Effect): self.create_horizontal_guideline("xheight", baseline+xheight) self.create_horizontal_guideline("descender", baseline-descender) + namedview = self.svg.find(inkex.addNS('namedview', 'sodipodi')) + namedview.set(inkex.addNS('document-units', 'inkscape'), 'px') + namedview.set(inkex.addNS('cx', 'inkscape'), str(emsize/2.0 )) + namedview.set(inkex.addNS('cy', 'inkscape'), str(emsize/2.0 )) + + if __name__ == '__main__': e = SetupTypographyCanvas() e.affect() |
