1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 16:07:57 +03:00

Add text-align-last

This commit is contained in:
Colin Kinloch 2021-07-06 13:47:47 +01:00
parent a267735f31
commit f586992af5
3 changed files with 15 additions and 2 deletions

View File

@ -148,6 +148,7 @@ INITIAL_VALUES = {
'letter_spacing': 'normal',
'tab_size': 8,
'text_align': 'start',
'text_align_last': 'auto',
'text_indent': Dimension(0, 'px'),
'text_transform': 'none',
'white_space': 'normal',
@ -258,6 +259,7 @@ INHERITED = {
'quotes',
'tab_size',
'text_align',
'text_align_last',
'text_decoration_line',
'text_decoration_color',
'text_decoration_style',

View File

@ -1067,6 +1067,13 @@ def text_align(keyword):
return keyword in ('left', 'right', 'center', 'justify', 'start', 'end')
@property()
@single_keyword
def text_align_last(keyword):
"""``text-align-last`` property validation."""
return keyword in ('auto', 'left', 'right', 'center', 'justify', 'start', 'end')
@property()
def text_decoration_line(tokens):
"""``text-decoration-line`` property validation."""

View File

@ -1313,6 +1313,12 @@ def text_align(context, line, available_width, last):
return 0
align = line.style['text_align']
align_last = line.style['text_align_last']
if last:
if align_last != 'auto':
align = align_last
elif align == 'justify':
align = 'start'
space_collapse = line.style['white_space'] in (
'normal', 'nowrap', 'pre-line')
if align in ('left', 'right'):
@ -1320,8 +1326,6 @@ def text_align(context, line, available_width, last):
align = 'start'
else:
align = 'end'
if align == 'justify' and last:
align = 'start'
if align == 'start':
return 0
offset = available_width - line.width