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

Merge branch 'master' of github.com:Kozea/WeasyPrint

This commit is contained in:
grewn0uille 2019-09-10 17:29:10 +02:00
commit c0fa009655
4 changed files with 21 additions and 7 deletions

View File

@ -225,7 +225,11 @@ def compute(element, pseudo_type, specified, computed, parent_style,
if computed_value is None:
new_value = None
else:
new_value = PROPERTIES[name.replace('_', '-')](computed_value)
prop = PROPERTIES[name.replace('_', '-')]
if prop.wants_base_url:
new_value = prop(computed_value, base_url)
else:
new_value = prop(computed_value)
# See https://drafts.csswg.org/css-variables/#invalid-variables
if new_value is None:

View File

@ -360,6 +360,9 @@ def parse_radial_gradient_parameters(arguments):
def parse_color_stop(tokens):
if len(tokens) == 1:
color = parse_color(tokens[0])
if color == 'currentColor':
# TODO: return the current color instead
return parse_color('black'), None
if color is not None:
return color, None
elif len(tokens) == 2:

View File

@ -91,8 +91,11 @@ def replacedbox_layout(box):
position = box.style['object_position']
image = box.replacement
iwidth, iheight = image.get_intrinsic_size(
intrinsic_width, intrinsic_height = image.get_intrinsic_size(
box.style['image_resolution'], box.style['font_size'])
if None in (intrinsic_width, intrinsic_height):
intrinsic_width, intrinsic_height = contain_constraint_image_sizing(
box.width, box.height, box.replacement.intrinsic_ratio)
if object_fit == 'fill':
draw_width, draw_height = box.width, box.height
@ -105,11 +108,11 @@ def replacedbox_layout(box):
box.width, box.height, box.replacement.intrinsic_ratio)
else:
assert object_fit == 'none', object_fit
draw_width, draw_height = iwidth, iheight
draw_width, draw_height = intrinsic_width, intrinsic_height
if object_fit == 'scale-down':
draw_width = min(draw_width, iwidth)
draw_height = min(draw_height, iheight)
draw_width = min(draw_width, intrinsic_width)
draw_height = min(draw_height, intrinsic_height)
origin_x, position_x, origin_y, position_y = position[0]
ref_x = box.width - draw_width

View File

@ -748,14 +748,18 @@ class Layout(object):
self.text = bytestring.decode('utf-8')
pango.pango_layout_set_text(self.layout, text, -1)
word_spacing = self.style['word_spacing']
# Word spacing may not be set if we're trying to get word-spacing
# computed value using a layout, for example if its unit is ex.
word_spacing = self.style.get('word_spacing', 0)
if justify:
# Justification is needed when drawing text but is useless during
# layout. Ignore it before layout is reactivated before the drawing
# step.
word_spacing += self.justification_spacing
letter_spacing = self.style['letter_spacing']
# Letter spacing may not be set if we're trying to get letter-spacing
# computed value using a layout, for example if its unit is ex.
letter_spacing = self.style.get('letter_spacing', 'normal')
if letter_spacing == 'normal':
letter_spacing = 0