1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00

Catch up with CairoSVG API changes.

This commit is contained in:
Simon Sapin 2012-01-19 17:11:40 +01:00
parent c3085d5088
commit 604219e376

View File

@ -83,30 +83,13 @@ def cairosvg_handler(file_like, uri):
try:
# Draw to a cairo surface but do not write to a file
tree = Tree(file_obj=file_like, url=uri)
surface = ScaledSVGSurface(tree, output=None)
surface = ScaledSVGSurface(tree, output=None, dpi=96)
except (ParseError, NotImplementedError) as exception:
return exception
pattern = cairo.SurfacePattern(surface.cairo)
return pattern, surface.width, surface.height
@apply
def _init_cairosvg():
"""Initialize cairosvgs DPI to 96 to match CSS pixels.
Do this only once when the module is imported so that it may be
overriden later.
"""
try:
import cairosvg as _
except ImportError:
pass
else:
from cairosvg.surface import units
units.DPI = 96
def fallback_handler(file_like, uri):
"""
Parse a byte stream with PIL and return a cairo Surface.