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,15 +2239,17 @@ def embedRasters(element, options) :
numRastersEmbedded += 1 numRastersEmbedded += 1
del b64eRaster del b64eRaster
def properlySizeDoc(docElement): def properlySizeDoc(docElement, options):
# get doc width and height # get doc width and height
w = SVGLength(docElement.getAttribute('width')) w = SVGLength(docElement.getAttribute('width'))
h = SVGLength(docElement.getAttribute('height')) 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.
if ((w.units != Unit.NONE and w.units != Unit.PX) or # well, it may be OK for Web browsers and vector editors, but not for librsvg.
(w.units != Unit.NONE and w.units != Unit.PX)): if options.renderer_workaround:
return if ((w.units != Unit.NONE and w.units != Unit.PX) or
(h.units != Unit.NONE and h.units != Unit.PX)):
return
# else we have a statically sized image and we should try to remedy that # 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) # properly size the SVG document (ideally width/height should be 100% with a viewBox)
if options.enable_viewboxing: if options.enable_viewboxing:
properlySizeDoc(doc.documentElement) properlySizeDoc(doc.documentElement, options)
# output the document as a pretty string with a single space for indent # output the document as a pretty string with a single space for indent
# NOTE: removed pretty printing because of this problem: # NOTE: removed pretty printing because of this problem: