Fix bug 576958 "Viewbox option doesn't work when units are set", when renderer workarounds are disabled.

This commit is contained in:
Cynthia Gauthier 2010-06-15 22:18:11 -04:00
parent f2285145d6
commit 2d28a5991d

View file

@ -2239,14 +2239,16 @@ def embedRasters(element, options) :
numRastersEmbedded += 1
del b64eRaster
def properlySizeDoc(docElement):
def properlySizeDoc(docElement, options):
# get doc width and height
w = SVGLength(docElement.getAttribute('width'))
h = SVGLength(docElement.getAttribute('height'))
# if width/height are not unitless or px then it is not ok to rewrite them into a viewBox
# if width/height are not unitless or px then it is not ok to rewrite them into a viewBox.
# well, it may be OK for Web browsers and vector editors, but not for librsvg.
if options.renderer_workaround:
if ((w.units != Unit.NONE and w.units != Unit.PX) or
(w.units != Unit.NONE and w.units != Unit.PX)):
(h.units != Unit.NONE and h.units != Unit.PX)):
return
# else we have a statically sized image and we should try to remedy that
@ -2592,7 +2594,7 @@ def scourString(in_string, options=None):
# properly size the SVG document (ideally width/height should be 100% with a viewBox)
if options.enable_viewboxing:
properlySizeDoc(doc.documentElement)
properlySizeDoc(doc.documentElement, options)
# output the document as a pretty string with a single space for indent
# NOTE: removed pretty printing because of this problem: