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

Draw column rules

This commit is contained in:
Guillaume Ayoub 2016-08-15 03:34:40 +02:00
parent 2de6429e53
commit e285acda8e
2 changed files with 22 additions and 1 deletions

View File

@ -67,7 +67,8 @@ PAGE_PSEUDOCLASS_TARGETS = {
# A test function that returns True if the given property name has an
# initial value that is not always the same when computed.
RE_INITIAL_NOT_COMPUTED = re.compile(
'^(display|column_gap|(border_[a-z]+|outline)_(width|color))$').match
'^(display|column_gap|'
'(border_[a-z]+|outline|column_rule)_(width|color))$').match
class StyleDict(object):

View File

@ -396,6 +396,26 @@ def draw_border(context, box, enable_hinting):
# We need a plan to draw beautiful borders, and that's difficult, no need
# to lie. Let's try to find the cases that we can handle in a smart way.
# Draw column borders
columns = (
box.style.column_width != 'auto' or
box.style.column_count != 'auto')
if columns and box.style.column_rule_width:
for child in box.children[1:]:
with stacked(context):
position_x = (child.position_x - (
box.style.column_rule_width + box.style.column_gap) / 2)
border_box = (
position_x, child.position_y, box.style.column_rule_width,
box.height)
clip_border_segment(
context, enable_hinting, box.style.column_rule_style,
box.style.column_rule_width, 'left', border_box)
draw_rect_border(
context, border_box,
(0, 0, 0, box.style.column_rule_width),
box.style.column_rule_style, box.style.column_rule_color)
# The box is hidden, easy.
if box.style.visibility != 'visible':
return