1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-08-17 16:40:45 +03:00

Use new pydyf API

This commit is contained in:
Guillaume Ayoub 2024-07-06 16:40:27 +02:00
parent 61852c4098
commit dd7cee28a0
6 changed files with 8 additions and 8 deletions

View File

@ -12,7 +12,7 @@ requires-python = '>=3.9'
readme = {file = 'README.rst', content-type = 'text/x-rst'}
license = {file = 'LICENSE'}
dependencies = [
'pydyf >=0.10.0',
'pydyf >=0.11.0',
'cffi >=0.6',
'html5lib >=1.1',
'tinycss2 >=1.3.0',

View File

@ -326,7 +326,7 @@ def draw_background_image(stream, layer, image_rendering):
with stacked(stream):
layer.image.draw(group, image_width, image_height, image_rendering)
pattern.draw_x_object(group.id)
stream.color_space('Pattern')
stream.set_color_space('Pattern')
stream.set_color_special(pattern.id)
if layer.unbounded:
x1, y1, x2, y2 = stream.page_rectangle

View File

@ -126,7 +126,7 @@ def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix):
utf8_text = textbox.pango_layout.text.encode()
previous_utf8_position = 0
stream.text_matrix(*matrix.values)
stream.set_text_matrix(*matrix.values)
last_font = None
string = ''
x_advance = 0

View File

@ -539,7 +539,7 @@ class Gradient:
alpha_stream.transform(d=scale_y)
alpha_stream.stream = [f'/{alpha_shading.id} sh']
stream.shading(shading.id)
stream.paint_shading(shading.id)
def layout(self, width, height):
"""Get layout information about the gradient.

View File

@ -53,7 +53,7 @@ class Stream(pydyf.Stream):
assert self._ctm_stack
def transform(self, a=1, b=0, c=0, d=1, e=0, f=0):
super().transform(a, b, c, d, e, f)
super().set_matrix(a, b, c, d, e, f)
self._ctm_stack[-1] = Matrix(a, b, c, d, e, f) @ self.ctm
def begin_text(self):

View File

@ -227,10 +227,10 @@ def draw_gradient(svg, node, gradient, font_size, opacity, stroke):
shading_type, 'Gray', domain, coords, extend, function)
alpha_stream.stream = [f'/{alpha_shading.id} sh']
group.shading(shading.id)
group.paint_shading(shading.id)
pattern.set_alpha(1)
pattern.draw_x_object(group.id)
svg.stream.color_space('Pattern', stroke=stroke)
svg.stream.set_color_space('Pattern', stroke=stroke)
svg.stream.set_color_special(pattern.id, stroke=stroke)
return True
@ -461,7 +461,7 @@ def draw_pattern(svg, node, pattern, font_size, opacity, stroke):
group, pattern_width, pattern_height, svg.base_url,
svg.url_fetcher, svg.context)
stream_pattern.draw_x_object(group.id)
svg.stream.color_space('Pattern', stroke=stroke)
svg.stream.set_color_space('Pattern', stroke=stroke)
svg.stream.set_color_special(stream_pattern.id, stroke=stroke)
return True