mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 00:21:15 +03:00
Fix the use of WeasyPrint's URL fetcher with CairoSVG
This commit is contained in:
parent
1c48e13d29
commit
c74b206abb
@ -119,6 +119,10 @@ class SVGImage(object):
|
||||
except Exception as e:
|
||||
raise ImageLoadingError.from_exception(e)
|
||||
|
||||
def _cairosvg_url_fetcher(self, src, mimetype):
|
||||
data = self._url_fetcher(src)
|
||||
return data.get('string', data['file_obj'].read())
|
||||
|
||||
def get_intrinsic_size(self, _image_resolution, font_size):
|
||||
# Vector images may be affected by the font size.
|
||||
fake_surface = FakeSurface()
|
||||
@ -155,7 +159,7 @@ class SVGImage(object):
|
||||
svg = ScaledSVGSurface(
|
||||
cairosvg.parser.Tree(
|
||||
bytestring=self._svg_data, url=self._base_url,
|
||||
url_fetcher=self._url_fetcher),
|
||||
url_fetcher=self._cairosvg_url_fetcher),
|
||||
output=None, dpi=96, parent_width=concrete_width,
|
||||
parent_height=concrete_height)
|
||||
if svg.width and svg.height:
|
||||
|
Loading…
Reference in New Issue
Block a user